File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,53 @@ import kotlin.test.assertTrue
1515
1616class ParserStructureConcatenationTest {
1717
18+ @Test
19+ fun concatFlattensOperations () {
20+ val parser = ParserStructure <Int >(
21+ operations = listOf (),
22+ followedBy = listOf (
23+ ParserStructure (
24+ operations = listOf (),
25+ followedBy = listOf (
26+ ParserStructure (
27+ operations = listOf (),
28+ followedBy = listOf (
29+ ParserStructure (
30+ operations = listOf (),
31+ followedBy = listOf (
32+ ParserStructure (
33+ operations = listOf (),
34+ followedBy = listOf (
35+ ParserStructure (
36+ operations = listOf (
37+ NumberSpanParserOperation (listOf (ConstantNumberConsumer (" 34" )))
38+ ),
39+ followedBy = listOf ()
40+ )
41+ )
42+ )
43+ )
44+ )
45+ )
46+ )
47+ )
48+ )
49+ )
50+ )
51+
52+ val actual = listOf (parser).concat()
53+
54+ with (actual) {
55+ assertTrue(operations.isEmpty())
56+ assertEquals(1 , followedBy.size)
57+ with (followedBy[0 ]) {
58+ assertEquals(1 , operations.size)
59+ assertTrue(operations[0 ] is NumberSpanParserOperation )
60+ assertTrue(followedBy.isEmpty())
61+ }
62+ }
63+ }
64+
1865 @Test
1966 fun concatDistributesTopLevelNumberSpanParserOperationIntoBranches () {
2067 val parser = ParserStructure <Int >(
You can’t perform that action at this time.
0 commit comments