File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,51 @@ import kotlin.test.assertTrue
1616
1717class ParserStructureConcatenationTest {
1818
19+ /*
20+ * --<N1>-- --<N1-N2>--<U>--
21+ * / /
22+ * --<N1>-- concat_with --<U>-- ==> --
23+ *
24+ * <N1>, <N2> - NumberSpanParserOperations
25+ * <U> - UnconditionalModification
26+ */
27+ // Reproducer from https://github.com/Kotlin/kotlinx-datetime/pull/585
28+ @Test
29+ fun concatDistributesNumberSpanParserOperation () {
30+ val actual = listOf (
31+ ParserStructure <Int >(
32+ operations = listOf (
33+ NumberSpanParserOperation (listOf (ConstantNumberConsumer (" 12" )))
34+ ),
35+ followedBy = listOf ()
36+ ),
37+ ParserStructure (
38+ operations = listOf (UnconditionalModification { }),
39+ followedBy = listOf (
40+ ParserStructure (
41+ operations = listOf (
42+ NumberSpanParserOperation (listOf (ConstantNumberConsumer (" 34" )))
43+ ),
44+ followedBy = listOf ()
45+ )
46+ )
47+ )
48+ ).concat()
49+
50+ with (actual) {
51+ assertTrue(operations.isEmpty())
52+ with (followedBy) {
53+ assertEquals(1 , size)
54+ with (this [0 ]) {
55+ assertEquals(2 , operations.size)
56+ assertTrue(operations[0 ] is NumberSpanParserOperation )
57+ assertEquals(2 , (operations[0 ] as NumberSpanParserOperation ).consumers.size)
58+ assertTrue(operations[1 ] is UnconditionalModification )
59+ }
60+ }
61+ }
62+ }
63+
1964 @Test
2065 fun concatDistributesUnconditionalModificationAfterNumberSpanParserOperation () {
2166 val actual = listOf (
You can’t perform that action at this time.
0 commit comments