Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f5833e7

Browse files
Add parser tests
1 parent 7cefee0 commit f5833e7

File tree

10 files changed

+643
-6
lines changed

10 files changed

+643
-6
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const QUERY = ['<"P">', '"P" "P"', 'P "P"'];
2+
3+
const PARSED = [
4+
{
5+
args: [],
6+
elemName: null,
7+
elems: [],
8+
foundElems: 0,
9+
id: "<\"P\">",
10+
nameSplit: null,
11+
original: "<\"P\">",
12+
returned: [],
13+
typeFilter: null,
14+
val: "<\"p\">",
15+
error: "`\"` cannot be used in generics",
16+
},
17+
{
18+
args: [],
19+
elemName: null,
20+
elems: [],
21+
foundElems: 0,
22+
id: "\"P\" \"P\"",
23+
nameSplit: null,
24+
original: "\"P\" \"P\"",
25+
returned: [],
26+
typeFilter: null,
27+
val: "\"p\" \"p\"",
28+
error: "Cannot have more than one literal search element",
29+
},
30+
{
31+
args: [],
32+
elemName: null,
33+
elems: [],
34+
foundElems: 0,
35+
id: "P \"P\"",
36+
nameSplit: null,
37+
original: "P \"P\"",
38+
returned: [],
39+
typeFilter: null,
40+
val: "p \"p\"",
41+
error: "Cannot use literal search when there is more than one element",
42+
},
43+
];
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const QUERY = ['fn:foo', 'enum : foo', 'macro<f>:foo'];
2+
3+
const PARSED = [
4+
{
5+
args: [],
6+
elemName: null,
7+
elems: [{
8+
name: "foo",
9+
fullPath: ["foo"],
10+
pathWithoutLast: [],
11+
pathLast: "foo",
12+
generics: [],
13+
}],
14+
foundElems: 1,
15+
id: "fn:foo",
16+
nameSplit: null,
17+
original: "fn:foo",
18+
returned: [],
19+
typeFilter: 5,
20+
val: "fn:foo",
21+
error: null,
22+
},
23+
{
24+
args: [],
25+
elemName: null,
26+
elems: [{
27+
name: "foo",
28+
fullPath: ["foo"],
29+
pathWithoutLast: [],
30+
pathLast: "foo",
31+
generics: [],
32+
}],
33+
foundElems: 1,
34+
id: "enum : foo",
35+
nameSplit: null,
36+
original: "enum : foo",
37+
returned: [],
38+
typeFilter: 4,
39+
val: "enum : foo",
40+
error: null,
41+
},
42+
{
43+
args: [],
44+
elemName: null,
45+
elems: [{
46+
name: "foo",
47+
fullPath: ["foo"],
48+
pathWithoutLast: [],
49+
pathLast: "foo",
50+
generics: [],
51+
}],
52+
foundElems: 1,
53+
id: "macro<f>:foo",
54+
nameSplit: null,
55+
original: "macro<f>:foo",
56+
returned: [],
57+
typeFilter: 14,
58+
val: "macro<f>:foo",
59+
error: null,
60+
},
61+
];
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const QUERY = ['<P>', 'A<B<C<D>, E>'];
2+
3+
const PARSED = [
4+
{
5+
args: [],
6+
elemName: null,
7+
elems: [{
8+
name: "",
9+
fullPath: [""],
10+
pathWithoutLast: [],
11+
pathLast: "",
12+
generics: [
13+
{
14+
name: "p",
15+
fullPath: ["p"],
16+
pathWithoutLast: [],
17+
pathLast: "p",
18+
generics: [],
19+
},
20+
],
21+
}],
22+
foundElems: 1,
23+
id: "<P>",
24+
nameSplit: null,
25+
original: "<P>",
26+
returned: [],
27+
typeFilter: -1,
28+
val: "<p>",
29+
error: null,
30+
},
31+
{
32+
args: [],
33+
elemName: null,
34+
elems: [{
35+
name: "a",
36+
fullPath: ["a"],
37+
pathWithoutLast: [],
38+
pathLast: "a",
39+
generics: [
40+
{
41+
name: "b",
42+
fullPath: ["b"],
43+
pathWithoutLast: [],
44+
pathLast: "b",
45+
generics: [
46+
{
47+
name: "c",
48+
fullPath: ["c"],
49+
pathWithoutLast: [],
50+
pathLast: "c",
51+
generics: [
52+
{
53+
name: "d",
54+
fullPath: ["d"],
55+
pathWithoutLast: [],
56+
pathLast: "d",
57+
generics: [],
58+
},
59+
],
60+
},
61+
{
62+
name: "e",
63+
fullPath: ["e"],
64+
pathWithoutLast: [],
65+
pathLast: "e",
66+
generics: [],
67+
},
68+
],
69+
},
70+
],
71+
}],
72+
foundElems: 1,
73+
id: 'A<B<C<D>, E>',
74+
nameSplit: null,
75+
original: 'A<B<C<D>, E>',
76+
returned: [],
77+
typeFilter: -1,
78+
val: 'a<b<c<d>, e>',
79+
error: null,
80+
}
81+
];
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const QUERY = ['(whatever)', '(<P>)'];
2+
3+
const PARSED = [
4+
{
5+
args: [{
6+
name: "whatever",
7+
fullPath: ["whatever"],
8+
pathWithoutLast: [],
9+
pathLast: "whatever",
10+
generics: [],
11+
}],
12+
elemName: null,
13+
elems: [],
14+
foundElems: 1,
15+
id: "(whatever)",
16+
nameSplit: null,
17+
original: "(whatever)",
18+
returned: [],
19+
typeFilter: -1,
20+
val: "(whatever)",
21+
error: null,
22+
},
23+
{
24+
args: [{
25+
name: "",
26+
fullPath: [""],
27+
pathWithoutLast: [],
28+
pathLast: "",
29+
generics: [
30+
{
31+
name: "p",
32+
fullPath: ["p"],
33+
pathWithoutLast: [],
34+
pathLast: "p",
35+
generics: [],
36+
},
37+
],
38+
}],
39+
elemName: null,
40+
elems: [],
41+
foundElems: 1,
42+
id: "(<P>)",
43+
nameSplit: null,
44+
original: "(<P>)",
45+
returned: [],
46+
typeFilter: -1,
47+
val: "(<p>)",
48+
error: null,
49+
},
50+
];
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// This test is mostly to check that the parser still kinda outputs something
2+
// (and doesn't enter an infinite loop!) even though the query is completely
3+
// invalid.
4+
const QUERY = ['-> <P> (p2)', '(p -> p2', 'a b', 'a,b(c)'];
5+
6+
const PARSED = [
7+
{
8+
args: [],
9+
elemName: null,
10+
elems: [],
11+
foundElems: 2,
12+
id: "-> <P> (p2)",
13+
nameSplit: null,
14+
original: "-> <P> (p2)",
15+
returned: [
16+
{
17+
name: "",
18+
fullPath: [""],
19+
pathWithoutLast: [],
20+
pathLast: "",
21+
generics: [
22+
{
23+
name: "p",
24+
fullPath: ["p"],
25+
pathWithoutLast: [],
26+
pathLast: "p",
27+
generics: [],
28+
},
29+
],
30+
},
31+
{
32+
name: "p2",
33+
fullPath: ["p2"],
34+
pathWithoutLast: [],
35+
pathLast: "p2",
36+
generics: [],
37+
},
38+
],
39+
typeFilter: -1,
40+
val: "-> <p> (p2)",
41+
error: null,
42+
},
43+
{
44+
args: [
45+
{
46+
name: "p",
47+
fullPath: ["p"],
48+
pathWithoutLast: [],
49+
pathLast: "p",
50+
generics: [],
51+
},
52+
{
53+
name: "p2",
54+
fullPath: ["p2"],
55+
pathWithoutLast: [],
56+
pathLast: "p2",
57+
generics: [],
58+
},
59+
],
60+
elemName: null,
61+
elems: [],
62+
foundElems: 2,
63+
id: "(p -> p2",
64+
nameSplit: null,
65+
original: "(p -> p2",
66+
returned: [],
67+
typeFilter: -1,
68+
val: "(p -> p2",
69+
error: null,
70+
},
71+
{
72+
args: [],
73+
elemName: null,
74+
elems: [
75+
{
76+
name: "a b",
77+
fullPath: ["a b"],
78+
pathWithoutLast: [],
79+
pathLast: "a b",
80+
generics: [],
81+
},
82+
],
83+
foundElems: 1,
84+
id: "a b",
85+
nameSplit: null,
86+
original: "a b",
87+
returned: [],
88+
typeFilter: -1,
89+
val: "a b",
90+
error: null,
91+
},
92+
{
93+
args: [
94+
{
95+
name: "c",
96+
fullPath: ["c"],
97+
pathWithoutLast: [],
98+
pathLast: "c",
99+
generics: [],
100+
},
101+
],
102+
elemName: null,
103+
elems: [
104+
{
105+
name: "a",
106+
fullPath: ["a"],
107+
pathWithoutLast: [],
108+
pathLast: "a",
109+
generics: [],
110+
},
111+
{
112+
name: "b",
113+
fullPath: ["b"],
114+
pathWithoutLast: [],
115+
pathLast: "b",
116+
generics: [],
117+
},
118+
],
119+
foundElems: 3,
120+
id: "a,b(c)",
121+
nameSplit: null,
122+
original: "a,b(c)",
123+
returned: [],
124+
typeFilter: -1,
125+
val: "a,b(c)",
126+
error: null,
127+
},
128+
];
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const QUERY = ['"R"<P>'];
2+
3+
const PARSED = [
4+
{
5+
args: [],
6+
elemName: null,
7+
elems: [{
8+
name: "r",
9+
fullPath: ["r"],
10+
pathWithoutLast: [],
11+
pathLast: "r",
12+
generics: [
13+
{
14+
name: "p",
15+
fullPath: ["p"],
16+
pathWithoutLast: [],
17+
pathLast: "p",
18+
generics: [],
19+
},
20+
],
21+
}],
22+
foundElems: 1,
23+
id: "\"R\"<P>",
24+
nameSplit: null,
25+
original: "\"R\"<P>",
26+
returned: [],
27+
typeFilter: -1,
28+
val: "\"r\"<p>",
29+
error: null,
30+
}
31+
];

0 commit comments

Comments
 (0)