@@ -109,7 +109,7 @@ end # testset
109109 K " NewlineWs" ,K " [" ,K " Integer" ,K " *" ,K " Integer" ,K " ," ,K " Integer" ,
110110 K " ;" ,K " Integer" ,K " ," ,K " Integer" ,K " ]" ,
111111
112- K " NewlineWs" ,K "\" " ,K " String" ,K "\" " ,K " ;" ,K " Whitespace" ,K " Char" ,
112+ K " NewlineWs" ,K "\" " ,K " String" ,K "\" " ,K " ;" ,K " Whitespace" ,K "' " , K " Char" , K " ' " ,
113113
114114 K " NewlineWs" ,K " (" ,K " Identifier" ,K " &&" ,K " Identifier" ,K " )" ,K " ||" ,
115115 K " (" ,K " Identifier" ,K " ||" ,K " Identifier" ,K " )" ,
@@ -130,7 +130,7 @@ end # testset
130130
131131 K " NewlineWs" ,K " {" ,K " }" ,
132132
133- K " NewlineWs" ,K "ErrorEofChar " ,K " EndMarker" ]
133+ K " NewlineWs" ,K "' " , K " Char " ,K " EndMarker" ]
134134
135135 for (i, n) in enumerate (tokenize (str))
136136 @test kind (n) == kinds[i]
@@ -190,6 +190,8 @@ function test_roundtrip(str, kind, val)
190190 @test untokenize (t, str) == val
191191end
192192
193+ roundtrip (str) = join (untokenize .(collect (tokenize (str)), str))
194+
193195@testset " tokenizing juxtaposed numbers and dotted operators/identifiers" begin
194196 test_roundtrip (" 1234 .+1" , K " Integer" , " 1234" )
195197 test_roundtrip (" 1234.0+1" , K " Float" , " 1234.0" )
@@ -228,22 +230,32 @@ end
228230 D = ImageMagick.load(fn)
229231 """
230232 tokens = collect (tokenize (str))
231- @test string (untokenize (tokens[16 ], str))== string (untokenize (tokens[17 ], str))== " '"
233+ @test string (untokenize (tokens[16 ], str)) == string (untokenize (tokens[17 ], str))== " '"
234+
235+ @test roundtrip (" 'a'" ) == " 'a'"
236+ @test kind .(collect (tokenize (" 'a'" ))) == [K " '" , K " Char" , K " '" , K " EndMarker" ]
237+
238+ # ' is not an operator here, so doesn't consume the suffix ᵀ
239+ @test roundtrip (" 'ᵀ'" ) == " 'ᵀ'"
240+ @test kind .(collect (tokenize (" '₁'" ))) == [K " '" , K " Char" , K " '" , K " EndMarker" ]
241+
242+ @test roundtrip (" ''" ) == " ''"
243+ @test kind .(collect (tokenize (" ''" ))) == [K " '" , K " '" , K " EndMarker" ]
244+
245+ @test roundtrip (" '''" ) == " '''"
246+ @test kind .(collect (tokenize (" '''" ))) == [K " '" , K " Char" , K " '" , K " EndMarker" ]
232247
233- test_roundtrip (" 'a'" , K " Char" , " 'a'" )
234- test_roundtrip (" ''" , K " Char" , " ''" )
235- test_roundtrip (" '''" , K " Char" , " '''" )
236- test_roundtrip (" ''''" , K " Char" , " '''" )
248+ @test roundtrip (" ''''" ) == " ''''"
249+ @test kind .(collect (tokenize (" ''''" ))) == [K " '" , K " Char" , K " '" , K " '" , K " EndMarker" ]
237250
238- @test tok (" ''''" , 1 ). kind == K " Char"
239- @test tok (" ''''" , 2 ). kind == K " '"
240251 @test tok (" ()'" , 3 ). kind == K " '"
241252 @test tok (" {}'" , 3 ). kind == K " '"
242253 @test tok (" []'" , 3 ). kind == K " '"
243254 @test tok (" outer'" , 2 ). kind == K " '"
244255 @test tok (" mutable'" , 2 ). kind == K " '"
245256 @test tok (" as'" , 2 ). kind == K " '"
246257 @test tok (" isa'" , 2 ). kind == K " '"
258+ @test untokenize .(collect (tokenize (" a'ᵀ" )), " a'ᵀ" ) == [" a" , " 'ᵀ" , " " ]
247259end
248260
249261@testset " keywords" begin
293305end
294306
295307@testset " errors" begin
296- @test tok (" #= #= =#" , 1 ). kind == K " ErrorEofMultiComment"
297- @test tok (" 'dsadsa" , 1 ). kind == K " ErrorEofChar"
298- @test tok (" aa **" , 3 ). kind == K " ErrorInvalidOperator"
308+ @test tok (" #= #= =#" , 1 ). kind == K " ErrorEofMultiComment"
309+ @test tok (" aa **" , 3 ). kind == K " ErrorInvalidOperator"
299310end
300311
301312@testset " xor_eq" begin
0 commit comments