mscgen_test.js 4.2 KB

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