Testing strategy for a new mode?

I am working a new mode to support PlantUML (see http://plantuml.sourceforge.net/ and http://www.planttext.com/).

I have an initial implementation but I am looking for the best way for testing: do you have any suggestions? How are the new modes normally tested?

My project is available here: https://github.com/ftomassetti/codemirror_plantuml


1 Like

See for example mode/javascript/test.js. The test/mode-test.js file defines a framework for writing out pieces of code annotated with expected token types. If you write a test file in that style and have test/index.html include it, the tests will be run as part of the test suite.

Thank you very much! I have been writing tens of tests BUT I seems to have problems with this one:

  MT("database package",
      "[keyword package] [def Node] <<[builtin Database]>> [bracket {]",
      "    [keyword class] [def Worker1]",
     "[bracket }]"

I think it is not parsing what I would expect because of “<<” and “>>”. Somehow they are messing up the interpreter.

< and > have no special interpretation in the mode-test minilanguage, so I don’t know what might be going wrong there. Maybe console.log the output of parseTokens in mode_test.js and wee if it differs from what you’d expect.