@@ -126,7 +126,7 @@ stackSafeLoopsTest = do
126
126
parseErrorTestPosition
127
127
(many1Till (string " a" ) (string " b" ))
128
128
" baa"
129
- (Position { line: 1 , column: 1 })
129
+ (Position { index: 0 , line: 1 , column: 1 })
130
130
131
131
parseTest " a,a,a,b,a,a" (toUnfoldable [ " a" , " a" , " a" ]) $
132
132
sepEndBy (string " a" ) (string " ," )
@@ -142,7 +142,7 @@ stackSafeLoopsTest = do
142
142
parseErrorTestPosition
143
143
(sepEndBy1 (string " a" ) (string " ," ))
144
144
" b,a,a"
145
- (Position { line: 1 , column: 1 })
145
+ (Position { index: 0 , line: 1 , column: 1 })
146
146
147
147
-- 8 `div` (8 `div` 2) == 2
148
148
parseTest " 8x8x2" 2 $
@@ -154,7 +154,7 @@ stackSafeLoopsTest = do
154
154
parseErrorTestPosition
155
155
(chainr1 digit (string " x" $> div))
156
156
" "
157
- (Position { line: 1 , column: 1 })
157
+ (Position { index: 0 , line: 1 , column: 1 })
158
158
159
159
-- (8 `div` 2) `div` 2 == 2
160
160
parseTest " 8x2x2" 2 $
@@ -166,15 +166,15 @@ stackSafeLoopsTest = do
166
166
parseErrorTestPosition
167
167
(chainl1 digit (string " x" $> div))
168
168
" "
169
- (Position { line: 1 , column: 1 })
169
+ (Position { index: 0 , line: 1 , column: 1 })
170
170
171
171
parseTest " aaaabcd" " b"
172
172
$ skipMany1 (string " a" )
173
173
*> string " b"
174
174
parseErrorTestPosition
175
175
(skipMany1 (string " a" ))
176
176
" bcd"
177
- (Position { line: 1 , column: 1 })
177
+ (Position { index: 0 , line: 1 , column: 1 })
178
178
179
179
parseTest " aaaabcd" " b"
180
180
$ skipMany (string " a" )
@@ -188,7 +188,7 @@ stackSafeLoopsTest = do
188
188
parseErrorTestPosition
189
189
(many1 (string " a" ))
190
190
" "
191
- (Position { line: 1 , column: 1 })
191
+ (Position { index: 0 , line: 1 , column: 1 })
192
192
193
193
parseTest " a,a,ab" (toUnfoldable [ " a" , " a" , " a" ])
194
194
$ sepBy (string " a" ) (string " ," )
@@ -202,11 +202,11 @@ stackSafeLoopsTest = do
202
202
parseErrorTestPosition
203
203
(sepBy1 (string " a" ) (string " ," ))
204
204
" "
205
- (Position { line: 1 , column: 1 })
205
+ (Position { index: 0 , line: 1 , column: 1 })
206
206
parseErrorTestPosition
207
207
(sepBy1 (string " a" ) (string " ," ))
208
208
" a,"
209
- (Position { line: 1 , column: 3 })
209
+ (Position { index: 2 , line: 1 , column: 3 })
210
210
211
211
parseTest " a,a,a,b" (toUnfoldable [ " a" , " a" , " a" ])
212
212
$ endBy (string " a" ) (string " ," )
@@ -220,11 +220,11 @@ stackSafeLoopsTest = do
220
220
parseErrorTestPosition
221
221
(endBy1 (string " a" ) (string " ," ))
222
222
" "
223
- (Position { line: 1 , column: 1 })
223
+ (Position { index: 0 , line: 1 , column: 1 })
224
224
parseErrorTestPosition
225
225
(endBy1 (string " a" ) (string " ," ))
226
226
" a,a"
227
- (Position { line: 1 , column: 4 })
227
+ (Position { index: 3 , line: 1 , column: 4 })
228
228
229
229
data TestToken = A | B
230
230
@@ -245,10 +245,7 @@ testTokenParser :: TokenParser
245
245
testTokenParser = makeTokenParser haskellDef
246
246
247
247
mkPos :: Int -> Position
248
- mkPos n = mkPos' n 1
249
-
250
- mkPos' :: Int -> Int -> Position
251
- mkPos' column line = Position { column: column, line: line }
248
+ mkPos n = Position { index: n - 1 , line: 1 , column: n }
252
249
253
250
type TestM = Effect Unit
254
251
@@ -575,12 +572,12 @@ main = do
575
572
parseErrorTestPosition
576
573
(many $ char ' f' *> char ' ?' )
577
574
" foo"
578
- (Position { column: 2 , line: 1 })
575
+ (Position { index: 1 , column: 2 , line: 1 })
579
576
580
577
parseErrorTestPosition
581
578
(satisfy (_ == ' ?' ))
582
579
" foo"
583
- (Position { column: 1 , line: 1 })
580
+ (Position { index: 0 , column: 1 , line: 1 })
584
581
585
582
parseTest
586
583
" foo"
@@ -605,17 +602,17 @@ main = do
605
602
606
603
parseTest " rest" " rest" rest
607
604
parseTest " rest" unit (rest *> eof)
608
- parseTest " rest\n rest" (Position { line: 2 , column: 5 }) (rest *> position)
605
+ parseTest " rest\n rest" (Position { index: 9 , line: 2 , column: 5 }) (rest *> position)
609
606
610
607
parseErrorTestPosition
611
608
(rest *> notFollowedBy eof)
612
609
" aa\n aa"
613
- (Position { column: 3 , line: 2 })
610
+ (Position { index: 5 , column: 3 , line: 2 })
614
611
615
612
parseErrorTestPosition
616
- anyChar
617
- " 𝅘𝅥𝅯"
618
- (Position { column: 1 , line: 1 })
613
+ (string " 𝅘𝅥𝅘𝅥𝅮 " *> string " 𝅘𝅥𝅘𝅥𝅮 " )
614
+ " 𝅘𝅥𝅘𝅥𝅮x 𝅘𝅥𝅯"
615
+ (Position { index: 2 , column: 3 , line: 1 })
619
616
620
617
parseTest " 𝅘𝅥𝅘𝅥𝅮x𝅘𝅥𝅯" [ " 𝅘𝅥" , " 𝅘𝅥𝅮" , " x" , " 𝅘𝅥𝅯" ] do
621
618
quarter <- anyCodePoint
@@ -631,8 +628,8 @@ main = do
631
628
632
629
parseTest " abcd" " ab" $ takeN 2
633
630
parseTest " abcd" " " $ takeN 0
634
- parseErrorTestPosition (takeN 10 ) " abcd" (Position { column: 1 , line: 1 })
635
- parseErrorTestPosition (takeN (-1 )) " abcd" (Position { column: 1 , line: 1 })
631
+ parseErrorTestPosition (takeN 10 ) " abcd" (Position { index: 0 , column: 1 , line: 1 })
632
+ parseErrorTestPosition (takeN (-1 )) " abcd" (Position { index: 0 , column: 1 , line: 1 })
636
633
637
634
parseErrorTestMessage
638
635
(noneOfCodePoints $ SCP .toCodePointArray " ❓✅" )
@@ -673,10 +670,10 @@ main = do
673
670
parseTest " ababab" [ ' b' , ' b' , ' b' ] $ Array .many (char ' a' *> char ' b' )
674
671
parseTest " abaXab" [ ' b' ] $ Array .many (try (char ' a' *> char ' b' ))
675
672
676
- parseErrorTestPosition (string " abc" ) " bcd" (Position { column: 1 , line: 1 })
677
- parseErrorTestPosition (string " abc" *> eof) " abcdefg" (Position { column: 4 , line: 1 })
678
- parseErrorTestPosition (string " a\n b\n c\n " *> eof) " a\n b\n c\n d\n " (Position { column: 1 , line: 4 })
679
- parseErrorTestPosition (string " \t a" *> eof) " \t ab" (Position { column: 10 , line: 1 })
673
+ parseErrorTestPosition (string " abc" ) " bcd" (Position { index: 0 , column: 1 , line: 1 })
674
+ parseErrorTestPosition (string " abc" *> eof) " abcdefg" (Position { index: 3 , column: 4 , line: 1 })
675
+ parseErrorTestPosition (string " a\n b\n c\n " *> eof) " a\n b\n c\n d\n " (Position { index: 6 , column: 1 , line: 4 })
676
+ parseErrorTestPosition (string " \t a" *> eof) " \t ab" (Position { index: 2 , column: 10 , line: 1 })
680
677
681
678
log " \n TESTS number\n "
682
679
0 commit comments