Skip to content

Commit f8a07d6

Browse files
committed
chore: fix tests
1 parent 6e151c6 commit f8a07d6

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

src/lake/Lake/Build/Module.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ private def fetchImportInfo
374374
else if n = 1 then -- common fast path
375375
let mod := mods[0]
376376
if imp.importAll && !mod.allowImportAll && pkgName != mod.pkg.name then
377-
logError s!"{fileName}: cannot 'import all' \
378-
the module `{imp.module}` from {mod.pkg.discriminant}"
377+
logError s!"{fileName}: cannot `import all` \
378+
the module `{imp.module}` from the package `{mod.pkg.discriminant}`"
379379
return .error
380380
let importJob ← mod.exportInfo.fetch
381381
return s.zipWith (sync := true) (·.addImport nonModule imp ·) importJob

tests/lake/tests/module/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public def foo : String := "bar"
2020
EOF
2121

2222
# Test cross-package `import all` is prevented by default
23-
test_err "cannot 'import all' across packages" build ErrorTest.CrossPackageImportAll
23+
test_err 'cannot `import all` the module' build ErrorTest.CrossPackageImportAll
2424
# Test cross-package `import all` is allowed when `allowImportAll = true` is set
2525
test_run build Test.CrossPackageImportAll
2626

tests/lake/tests/toml/Test.lean

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8080
mutual
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

134134
def 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

Comments
 (0)