xu_test.js 4.7 KB

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