mscgen_test.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({indentUnit: 2}, "mscgen");
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  6. MT("empty chart",
  7. "[keyword msc][bracket {]",
  8. "[base ]",
  9. "[bracket }]"
  10. );
  11. MT("comments",
  12. "[comment // a single line comment]",
  13. "[comment # another single line comment /* and */ ignored here]",
  14. "[comment /* A multi-line comment even though it contains]",
  15. "[comment msc keywords and \"quoted text\"*/]");
  16. MT("strings",
  17. "[string \"// a string\"]",
  18. "[string \"a string running over]",
  19. "[string two lines\"]",
  20. "[string \"with \\\"escaped quote\"]"
  21. );
  22. MT("xù/ msgenny keywords classify as 'base'",
  23. "[base watermark]",
  24. "[base alt loop opt ref else break par seq assert]"
  25. );
  26. MT("xù/ msgenny constants classify as 'base'",
  27. "[base auto]"
  28. );
  29. MT("mscgen constants classify as 'variable'",
  30. "[variable true]", "[variable false]", "[variable on]", "[variable off]"
  31. );
  32. MT("mscgen options classify as keyword",
  33. "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
  34. );
  35. MT("mscgen arcs classify as keyword",
  36. "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
  37. "[keyword |||...---]", "[keyword ..--==::]",
  38. "[keyword ->]", "[keyword <-]", "[keyword <->]",
  39. "[keyword =>]", "[keyword <=]", "[keyword <=>]",
  40. "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
  41. "[keyword >>]", "[keyword <<]", "[keyword <<>>]",
  42. "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
  43. "[keyword :>]", "[keyword <:]", "[keyword <:>]"
  44. );
  45. MT("within an attribute list, attributes classify as attribute",
  46. "[bracket [[][attribute label]",
  47. "[attribute id]","[attribute url]","[attribute idurl]",
  48. "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
  49. "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
  50. "[attribute arcskip][bracket ]]]"
  51. );
  52. MT("outside an attribute list, attributes classify as base",
  53. "[base label]",
  54. "[base id]","[base url]","[base idurl]",
  55. "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
  56. "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
  57. "[base arcskip]"
  58. );
  59. MT("a typical program",
  60. "[comment # typical mscgen program]",
  61. "[keyword msc][base ][bracket {]",
  62. "[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]",
  63. "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
  64. "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
  65. "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
  66. "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
  67. "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]",
  68. "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
  69. "[bracket }]"
  70. );
  71. })();