Skip to content

Commit 0b35f6d

Browse files
committed
Add tests for nested categories
1 parent 67dff03 commit 0b35f6d

File tree

2 files changed

+310
-0
lines changed

2 files changed

+310
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
module lang::textmate::conversiontests::NestedCategories
2+
3+
import Grammar;
4+
import ParseTree;
5+
import util::Maybe;
6+
7+
import lang::textmate::Conversion;
8+
import lang::textmate::ConversionConstants;
9+
import lang::textmate::ConversionTests;
10+
import lang::textmate::ConversionUnit;
11+
12+
start syntax Start
13+
= A01 | A02 | A03 | A04 | A05 | A06 | A07 | A08 | A09 | A10 | A11 | A12;
14+
15+
lexical A01 = @category="a" B01 [\ ] C01;
16+
lexical B01 = @category="b" D01 [\ ] "bar01";
17+
lexical C01 = @category="c" D01 [\ ] "baz01";
18+
lexical D01 = @category="d" "foo01";
19+
20+
lexical A02 = @category="a" B02 [\ ] C02;
21+
lexical B02 = @category="b" D02 [\ ] "bar02";
22+
lexical C02 = @category="c" D02 [\ ] "baz02";
23+
lexical D02 = "foo02";
24+
25+
lexical A03 = @category="a" B03 [\ ] C03;
26+
lexical B03 = @category="b" D03 [\ ] "bar03";
27+
lexical C03 = D03 [\ ] "baz03";
28+
lexical D03 = @category="d" "foo03";
29+
30+
lexical A04 = @category="a" B04 [\ ] C04;
31+
lexical B04 = @category="b" D04 [\ ] "bar04";
32+
lexical C04 = D04 [\ ] "baz04";
33+
lexical D04 = "foo04";
34+
35+
lexical A05 = @category="a" B05 [\ ] C05;
36+
lexical B05 = D05 [\ ] "bar05";
37+
lexical C05 = D05 [\ ] "baz05";
38+
lexical D05 = @category="d" "foo05";
39+
40+
lexical A06 = @category="a" B06 [\ ] C06;
41+
lexical B06 = D06 [\ ] "bar06";
42+
lexical C06 = D06 [\ ] "baz06";
43+
lexical D06 = "foo06";
44+
45+
lexical A07 = B07 [\ ] C07;
46+
lexical B07 = @category="b" D07 [\ ] "bar07";
47+
lexical C07 = @category="c" D07 [\ ] "baz07";
48+
lexical D07 = @category="d" "foo07";
49+
50+
lexical A08 = B08 [\ ] C08;
51+
lexical B08 = @category="b" D08 [\ ] "bar08";
52+
lexical C08 = @category="c" D08 [\ ] "baz08";
53+
lexical D08 = "foo08";
54+
55+
lexical A09 = B09 [\ ] C09;
56+
lexical B09 = @category="b" D09 [\ ] "bar09";
57+
lexical C09 = D09 [\ ] "baz09";
58+
lexical D09 = @category="d" "foo09"; // Design decision: D09 should be converted
59+
// to a TextMate rule, because it's
60+
// reachable via C09, which doesn't have a
61+
// category
62+
63+
lexical A10 = B10 [\ ] C10;
64+
lexical B10 = @category="b" D10 [\ ] "bar10";
65+
lexical C10 = D10 [\ ] "baz10";
66+
lexical D10 = "foo10";
67+
68+
lexical A11 = B11 [\ ] C11;
69+
lexical B11 = D11 [\ ] "bar11";
70+
lexical C11 = D11 [\ ] "baz11";
71+
lexical D11 = @category="d" "foo11";
72+
73+
lexical A12 = B12 [\ ] C12;
74+
lexical B12 = D12 [\ ] "bar12";
75+
lexical C12 = D12 [\ ] "baz12";
76+
lexical D12 = "foo12";
77+
78+
Grammar rsc = preprocess(grammar(#Start));
79+
80+
list[ConversionUnit] units = [
81+
unit(rsc, prod(lex("C07"),[lex("D07"),lit(" "),lit("baz07")],{\tag("category"("c"))}), false, false, <just(lit(" ")),nothing()>, <nothing(),nothing()>),
82+
unit(rsc, prod(lex("C08"),[lex("D08"),lit(" "),lit("baz08")],{\tag("category"("c"))}), false, false, <just(lit(" ")),nothing()>, <nothing(),nothing()>),
83+
unit(rsc, prod(lex("A01"),[lex("B01"),lit(" "),lex("C01")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>),
84+
unit(rsc, prod(lex("A02"),[lex("B02"),lit(" "),lex("C02")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>),
85+
unit(rsc, prod(lex("A03"),[lex("B03"),lit(" "),lex("C03")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>),
86+
unit(rsc, prod(lex("A04"),[lex("B04"),lit(" "),lex("C04")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>),
87+
unit(rsc, prod(lex("A05"),[lex("B05"),lit(" "),lex("C05")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>),
88+
unit(rsc, prod(lex("A06"),[lex("B06"),lit(" "),lex("C06")],{\tag("category"("a"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>),
89+
unit(rsc, prod(lex("B07"),[lex("D07"),lit(" "),lit("bar07")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>),
90+
unit(rsc, prod(lex("B08"),[lex("D08"),lit(" "),lit("bar08")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>),
91+
unit(rsc, prod(lex("B09"),[lex("D09"),lit(" "),lit("bar09")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>),
92+
unit(rsc, prod(lex("B10"),[lex("D10"),lit(" "),lit("bar10")],{\tag("category"("b"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>),
93+
unit(rsc, prod(lex("D09"),[lit("foo09")],{\tag("category"("d"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>),
94+
unit(rsc, prod(lex("D11"),[lit("foo11")],{\tag("category"("d"))}), false, false, <nothing(),just(lit(" "))>, <nothing(),nothing()>),
95+
unit(rsc, prod(lex(KEYWORDS_PRODUCTION_NAME),[alt({lit("foo07"),lit("foo06"),lit("foo09"),lit("foo08"),lit("foo03"),lit("foo02"),lit("foo05"),lit("foo04"),lit("foo10"),lit("baz09"),lit("foo11"),lit("baz06"),lit("baz05"),lit("baz08"),lit("baz07"),lit("baz02"),lit("baz04"),lit("baz03"),lit("bar06"),lit("bar05"),lit("bar02"),lit("bar04"),lit("bar03"),lit("bar11"),lit("bar10"),lit("foo12"),lit("foo01"),lit("baz12"),lit("baz01"),lit("bar09"),lit("baz11"),lit("bar08"),lit("baz10"),lit("bar07"),lit("bar12"),lit("bar01")})],{\tag("category"("keyword.control"))}), false, false, <nothing(),nothing()>, <nothing(),nothing()>)
96+
];
97+
98+
test bool analyzeTest() = doAnalyzeTest(rsc, units, name = "NestedCategories");
99+
test bool transformTest() = doTransformTest(units, <15, 0, 0>, name = "NestedCategories");
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# SYNTAX TEST "NestedCategories"
2+
3+
foo01 bar01 foo01 baz01
4+
# ^ a
5+
# ^^^^^^ b
6+
# ^^^^^^ c
7+
# ^^^^^ ^^^^^ d
8+
9+
foo01 bar01
10+
# ^^^^^^^^^^^ -b
11+
# ^^^^^ -d
12+
13+
foo01 baz01
14+
# ^^^^^^^^^^^ -c
15+
# ^^^^^ -d
16+
17+
foo01
18+
# ^^^^^ -d
19+
20+
foo02 bar02 foo02 baz02
21+
# ^ a
22+
# ^^^^^^^^^^^ b
23+
# ^^^^^^^^^^^ c
24+
# ^^^^^ ^^^^^ -d
25+
26+
foo02 bar02
27+
# ^^^^^^^^^^^ -b
28+
# ^^^^^ -d
29+
30+
foo02 baz02
31+
# ^^^^^^^^^^^ -c
32+
# ^^^^^ -d
33+
34+
foo02
35+
# ^^^^^ -d
36+
37+
foo03 bar03 foo03 baz03
38+
# ^ ^^^^^^ a
39+
# ^^^^^^ b
40+
# ^^^^^^^^^^^ -c
41+
# ^^^^^ ^^^^^ d
42+
43+
foo03 bar03
44+
# ^^^^^^^^^^^ -b
45+
# ^^^^^ -d
46+
47+
foo03 baz03
48+
# ^^^^^^^^^^^ -c
49+
# ^^^^^ -d
50+
51+
foo03
52+
# ^^^^^ -d
53+
54+
foo04 bar04 foo04 baz04
55+
# ^^^^^^^^^^^^ a
56+
# ^^^^^^^^^^^ b
57+
# ^^^^^^^^^^^ -c
58+
# ^^^^^ ^^^^^ -d
59+
60+
foo04 bar04
61+
# ^^^^^^^^^^^ -b
62+
# ^^^^^ -d
63+
64+
foo04 baz04
65+
# ^^^^^^^^^^^ -c
66+
# ^^^^^ -d
67+
68+
foo04
69+
# ^^^^^ -d
70+
71+
foo05 bar05 foo05 baz05
72+
# ^^^^^^^ ^^^^^^ a
73+
# ^^^^^^^^^^^ -b
74+
# ^^^^^^^^^^^ -c
75+
# ^^^^^ ^^^^^ d
76+
77+
foo05 bar05
78+
# ^^^^^^^^^^^ -b
79+
# ^^^^^ -d
80+
81+
foo05 baz05
82+
# ^^^^^^^^^^^ -c
83+
# ^^^^^ -d
84+
85+
foo05
86+
# ^^^^^ -d
87+
88+
foo06 bar06 foo06 baz06
89+
# ^^^^^^^^^^^^^^^^^^^^^^^ a
90+
# ^^^^^^^^^^^ -b
91+
# ^^^^^^^^^^^ -c
92+
# ^^^^^ ^^^^^ -d
93+
94+
foo06 bar06
95+
# ^^^^^^^^^^^ -b
96+
# ^^^^^ -d
97+
98+
foo06 baz06
99+
# ^^^^^^^^^^^ -c
100+
# ^^^^^ -d
101+
102+
foo06
103+
# ^^^^^ -d
104+
105+
foo07 bar07 foo07 baz07
106+
# ^^^^^^^^^^^^^^^^^^^^^^^ -a
107+
# ^^^^^^ b
108+
# ^^^^^^ c
109+
# ^^^^^ ^^^^^ d
110+
111+
foo07 bar07
112+
# ^^^^^^ b
113+
# ^^^^^ d
114+
115+
foo07 baz07
116+
# ^^^^^^ c
117+
# ^^^^^ d
118+
119+
foo07
120+
# ^^^^^ -d
121+
122+
foo08 bar08 foo08 baz08
123+
# ^^^^^^^^^^^^^^^^^^^^^^^ -a
124+
# ^^^^^^^^^^^ b
125+
# ^^^^^^^^^^^ c
126+
# ^^^^^ ^^^^^ -d
127+
128+
foo08 bar08
129+
# ^^^^^^^^^^^ b
130+
# ^^^^^ -d
131+
132+
foo08 baz08
133+
# ^^^^^^^^^^^ c
134+
# ^^^^^ -d
135+
136+
foo08
137+
# ^^^^^ -d
138+
139+
foo09 bar09 foo09 baz09
140+
# ^^^^^^^^^^^^^^^^^^^^^^^ -a
141+
# ^^^^^^ b
142+
# ^^^^^^^^^^^ -c
143+
# ^^^^^ ^^^^^ d
144+
145+
foo09 bar09
146+
# ^^^^^^ b
147+
# ^^^^^ d
148+
149+
foo09 baz09
150+
# ^^^^^^^^^^^ -c
151+
# ^^^^^ d
152+
153+
foo09
154+
# ^^^^^ d
155+
156+
foo10 bar10 foo10 baz10
157+
# ^^^^^^^^^^^^^^^^^^^^^^^ -a
158+
# ^^^^^^^^^^^ b
159+
# ^^^^^^^^^^^ -c
160+
# ^^^^^ ^^^^^ -d
161+
162+
foo10 bar10
163+
# ^^^^^^^^^^^ b
164+
# ^^^^^ -d
165+
166+
foo10 baz10
167+
# ^^^^^^^^^^^ -c
168+
# ^^^^^ -d
169+
170+
foo10
171+
# ^^^^^ -d
172+
173+
foo11 bar11 foo11 baz11
174+
# ^^^^^^^^^^^^^^^^^^^^^^^ -a
175+
# ^^^^^^^^^^^ -b
176+
# ^^^^^^^^^^^ -c
177+
# ^^^^^ ^^^^^ d
178+
179+
foo11 bar11
180+
# ^^^^^^^^^^^ -b
181+
# ^^^^^ d
182+
183+
foo11 baz11
184+
# ^^^^^^^^^^^ -c
185+
# ^^^^^ d
186+
187+
foo11
188+
# ^^^^^ d
189+
190+
foo12 bar12 foo12 baz12
191+
# ^^^^^^^^^^^^^^^^^^^^^^^ -a
192+
# ^^^^^^^^^^^ -b
193+
# ^^^^^^^^^^^ -c
194+
# ^^^^^ ^^^^^ -d
195+
196+
foo11 bar11 foo11 baz11
197+
# ^^^^^^^^^^^^^^^^^^^^^^^ -a
198+
# ^^^^^^^^^^^ -b
199+
# ^^^^^^^^^^^ -c
200+
# ^^^^^ ^^^^^ d
201+
202+
foo12 bar12
203+
# ^^^^^^^^^^^ -b
204+
# ^^^^^ -d
205+
206+
foo12 baz12
207+
# ^^^^^^^^^^^ -c
208+
# ^^^^^ -d
209+
210+
foo12
211+
# ^^^^^ -d

0 commit comments

Comments
 (0)