mirror of
https://github.com/leanprover/lean4.git
synced 2026-03-17 18:34:06 +00:00
This PR sets up the new integrated test/bench suite. It then migrates all benchmarks and some related tests to the new suite. There's also some documentation and some linting. For now, a lot of the old tests are left alone so this PR doesn't become even larger than it already is. Eventually, all tests should be migrated to the new suite though so there isn't a confusing mix of two systems.
57 lines
1.7 KiB
Lean4
57 lines
1.7 KiB
Lean4
open System
|
|
open System.Platform
|
|
|
|
def norm (f : FilePath) : String :=
|
|
f.toString.map fun c => if c == '\\' then '/' else c
|
|
|
|
#eval FilePath.isAbsolute (if isWindows then "C:\\foo" else "/foo")
|
|
#eval FilePath.isAbsolute "a/b"
|
|
|
|
#eval norm <| ("a" : FilePath) / "b"
|
|
#eval norm <| ("a" : FilePath) / "b" / "c"
|
|
#eval norm <| ("a" : FilePath) / "/b/c"
|
|
|
|
#eval norm <$> FilePath.parent "a/b"
|
|
#eval norm <$> FilePath.parent "a/b/c"
|
|
#eval norm <$> FilePath.parent "a"
|
|
|
|
/-! Test FilePath.parent with absolute paths general cases -/
|
|
#eval norm <$> FilePath.parent "/a/b/c"
|
|
#eval norm <$> FilePath.parent "/a"
|
|
#eval norm <$> FilePath.parent "/aaa"
|
|
#eval norm <$> FilePath.parent "/"
|
|
|
|
/-!
|
|
Test FilePath.parent with absolute paths for OS specific cases
|
|
Some of these tests are not meaningful on Unix but are included for clarity
|
|
-/
|
|
def testParentAcrossOS (p : FilePath) (windowsParent : Option String) (unixParent : Option String) : Bool :=
|
|
if isWindows then
|
|
p.parent == windowsParent
|
|
else
|
|
p.parent == unixParent
|
|
|
|
|
|
#eval testParentAcrossOS "c:/a/b" "c:/a" "c:/a"
|
|
#eval testParentAcrossOS "c:/a" "c:/" "c:"
|
|
#eval testParentAcrossOS "c:/" none "c:"
|
|
#eval testParentAcrossOS "c:" none none
|
|
|
|
#eval FilePath.fileName "a/b"
|
|
|
|
#eval FilePath.fileStem "a/b"
|
|
#eval FilePath.fileStem "a/b.tar.gz"
|
|
#eval FilePath.fileStem "a/.gitignore"
|
|
|
|
#eval norm <| FilePath.withFileName "a/b" "c"
|
|
|
|
#eval FilePath.extension "a/b"
|
|
#eval FilePath.extension "a/b.txt"
|
|
#eval FilePath.extension "a/.gitignore"
|
|
|
|
#eval norm <| FilePath.withExtension "a/b.tar.gz" "xz"
|
|
#eval norm <| FilePath.withExtension "a/b.tar.gz" ""
|
|
#eval norm <| FilePath.withExtension "a/b" "tar.gz"
|
|
|
|
#eval norm <| FilePath.addExtension "a/b.tar.gz" "bak"
|