all repos — NoPaste @ 29b774f090102303e43cf939b38ac2083e62d9f1

Resurrected - The PussTheCat.org fork of NoPaste

scripts/CodeMirror/mode/mscgen/xu_test.js (view raw)

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