xu_test.js 3.9 KB

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