mscgen_test.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://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("mscgen options classify as keyword",
  27. "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
  28. );
  29. MT("mscgen arcs classify as keyword",
  30. "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
  31. "[keyword |||...---]", "[keyword ..--==::]",
  32. "[keyword ->]", "[keyword <-]", "[keyword <->]",
  33. "[keyword =>]", "[keyword <=]", "[keyword <=>]",
  34. "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
  35. "[keyword >>]", "[keyword <<]", "[keyword <<>>]",
  36. "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
  37. "[keyword :>]", "[keyword <:]", "[keyword <:>]"
  38. );
  39. MT("within an attribute list, attributes classify as attribute",
  40. "[bracket [[][attribute label]",
  41. "[attribute id]","[attribute url]","[attribute idurl]",
  42. "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
  43. "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
  44. "[attribute arcskip][bracket ]]]"
  45. );
  46. MT("outside an attribute list, attributes classify as base",
  47. "[base label]",
  48. "[base id]","[base url]","[base idurl]",
  49. "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
  50. "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
  51. "[base arcskip]"
  52. );
  53. MT("a typical program",
  54. "[comment # typical mscgen program]",
  55. "[keyword msc][base ][bracket {]",
  56. "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]",
  57. "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
  58. "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
  59. "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
  60. "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
  61. "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]",
  62. "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
  63. "[bracket }]"
  64. );
  65. })();