File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,46 @@ package kotlinx.datetime.test.format
88import kotlinx.datetime.internal.format.parser.ConstantNumberConsumer
99import kotlinx.datetime.internal.format.parser.NumberSpanParserOperation
1010import kotlinx.datetime.internal.format.parser.ParserStructure
11+ import kotlinx.datetime.internal.format.parser.UnconditionalModification
1112import kotlinx.datetime.internal.format.parser.concat
1213import kotlin.test.Test
1314import kotlin.test.assertEquals
1415import kotlin.test.assertTrue
1516
1617class ParserStructureConcatenationTest {
1718
19+ @Test
20+ fun concatDistributesUnconditionalModificationAfterNumberSpanParserOperation () {
21+ val parser = ParserStructure <Int >(
22+ operations = listOf (
23+ UnconditionalModification { }
24+ ),
25+ followedBy = listOf (
26+ ParserStructure (
27+ operations = listOf (
28+ NumberSpanParserOperation (listOf (ConstantNumberConsumer (" 34" )))
29+ ),
30+ followedBy = listOf ()
31+ )
32+ )
33+ )
34+
35+ val actual = listOf (parser).concat()
36+
37+ with (actual) {
38+ assertTrue(operations.isEmpty())
39+ with (followedBy) {
40+ assertEquals(1 , size)
41+ with (followedBy[0 ]) {
42+ assertEquals(2 , operations.size)
43+ assertTrue(operations[0 ] is NumberSpanParserOperation )
44+ assertTrue(operations[1 ] is UnconditionalModification )
45+ assertTrue(followedBy.isEmpty())
46+ }
47+ }
48+ }
49+ }
50+
1851 @Test
1952 fun concatFlattensOperations () {
2053 val parser = ParserStructure <Int >(
You can’t perform that action at this time.
0 commit comments