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