@@ -69,13 +69,13 @@ def expectPrimitive (actualTy : String) (expected : Json) : Except String String
6969 throw s! "expected value of type '{ ty} ', got '{ actualTy} '"
7070 return val
7171
72- def decodeSign (s : String) : Bool × String :=
72+ def decodeSign (s : String) : Bool × String.Slice :=
7373 if s.front == '-' then
7474 (true , s.drop 1 )
7575 else if s.front == '+' then
7676 (false , s.drop 1 )
7777 else
78- (false , s)
78+ (false , s.toSlice )
7979
8080mutual
8181
@@ -91,13 +91,13 @@ partial def expectValue (actual : Value) (expected : Json) : Except String Unit
9191 throw s! "expected '{ expected} ', got '{ actN} '"
9292 else
9393 let (neg, e) := decodeSign expected
94- if e.toLower == "inf" then
94+ if e.eqIgnoreAsciiCase "inf" .toSlice then
9595 unless actN.isInf && neg == (actN < 0 ) do
9696 throw s! "expected '{ e} ', got '{ actN} '"
9797 else
9898 let some flt :=
9999 (Nat.toFloat <$> e.toNat?) <|>
100- (Syntax.decodeScientificLitVal? e |>.map fun (m,s,e) => .ofScientific m s e)
100+ (Syntax.decodeScientificLitVal? e.copy |>.map fun (m,s,e) => Float .ofScientific m s e)
101101 | throw s! "failed to parse expected float value: { e} "
102102 expectBEq actN <| if neg then -flt else flt
103103 | .dateTime _ dt =>
@@ -132,11 +132,6 @@ def expectJson (actual expected : Json) : TestOutcome :=
132132 if actual == expected then .pass s else .fail s
133133
134134def testValid (tomlFile : FilePath) : BaseIO TestOutcome := do
135- -- Tests skipped due to bugs in Lean's JSON parser
136- -- TODO: Fix JSON parser (high-low unicode escape pairs)
137- let normPath := tomlFile.toString.map fun c => if c = '\\ ' then '/' else c
138- for testPath in ["string/quoted-unicode.toml" , "key/quoted-unicode.toml" ] do
139- if normPath.endsWith testPath then return .skip
140135 match (← loadToml tomlFile) with
141136 | .pass t =>
142137 match (← IO.FS.readFile (tomlFile.withExtension "json" ) |>.toBaseIO) with
@@ -145,7 +140,7 @@ def testValid (tomlFile : FilePath) : BaseIO TestOutcome := do
145140 | .ok j =>
146141 match expectTable t j with
147142 | .ok _ => return .pass <| ppTable t
148- | .error e => return .fail <| e.trimRight .push '\n '
143+ | .error e => return .fail <| e.trimAsciiEnd.copy .push '\n '
149144 | .error e => return .error s! "invalid JSON: { e} "
150145 | .error e => return .error (toString e)
151146 | .fail l => return .fail (← mkMessageLogString l)
0 commit comments