Fixed some tests.
h3rald h3rald@h3rald.com
Sun, 26 May 2024 12:22:46 +0200
5 files changed,
18 insertions(+),
16 deletions(-)
M
minpkg/core/scope.nim
→
minpkg/core/scope.nim
@@ -1,5 +1,5 @@
import - std/[strutils, sequtils, critbits] + std/[strutils, critbits] import parser@@ -25,7 +25,7 @@ var keys = key.split(".")
return getSymbolFromPath(scope, keys, acc) else: if scope.parent.isNil: - raiseUndefined("Symbol '$1' not found." % key) + raiseUndefined("Unable to retrieve symbol '$1' (not found)." % key) return scope.parent.getSymbol(key, acc + 1) proc getSymbolFromPath(scope: ref MinScope, keys: var seq[@@ -49,8 +49,10 @@ if scope.isNil:
return false elif scope.symbols.hasKey(key): return true - elif key.contains ".": + elif key.contains("."): var keys = key.split(".") + if keys[0] == "": + raiseInvalid("Symbols cannot start with a dot") return hasSymbolFromPath(scope, keys) elif not scope.parent.isNil: return scope.parent.hasSymbol(key)
M
minpkg/lib/min_sys.nim
→
minpkg/lib/min_sys.nim
@@ -17,10 +17,10 @@
proc sys_module*(i: In) = let def = i.define() - def.symbol(".") do (i: In): + def.symbol("pwd") do (i: In): i.push newVal(getCurrentDir().unix) - def.symbol("..") do (i: In): + def.symbol("parent-dir") do (i: In): i.push newVal(getCurrentDir().parentDir.unix) def.symbol("cd") do (i: In):
M
tests/fs.min
→
tests/fs.min
@@ -27,13 +27,13 @@ ("/home/h3rald" windows-path "\\home\\h3rald" ==) test.assert
("/home/h3rald" absolute-path?) test.assert - ("tests/sys.min" expand-filename unix-path . "/tests/sys.min" suffix unix-path ==) test.assert + ("tests/sys.min" expand-filename unix-path pwd "/tests/sys.min" suffix unix-path ==) test.assert ("./../tests" normalized-path unix-path "../tests" ==) test.assert - ((. "tests/global.min") => join-path . relative-path unix-path "tests/global.min" ==) test.assert + ((pwd "tests/global.min") => join-path pwd relative-path unix-path "tests/global.min" ==) test.assert - ("tests/global.min" absolute-path unix-path (. "tests/global.min") => join-path unix-path ==) test.assert + ("tests/global.min" absolute-path unix-path (pwd "tests/global.min") => join-path unix-path ==) test.assert ("./test" absolute-path? not) test.assert
M
tests/str.min
→
tests/str.min
@@ -57,7 +57,7 @@ ("test" 4 indent " test" ==) test.assert
((1 3 "test") ", " join "1, 3, test" ==) test.assert - ("PWD: $pwd" ("pwd" .) =% ("PWD: " .) => "" join ==) test.assert + ("PWD: $pwd" ("pwd" pwd) =% ("PWD: " pwd) => "" join ==) test.assert ("1.2.3" from-semver {1 :major 2 :minor 3 :patch} ==) test.assert
M
tests/sys.min
→
tests/sys.min
@@ -25,10 +25,10 @@ ('dir2 ls 'dirname map ("dir2") ==) test.assert
('dir1 rmdir 'dir2 rmdir 'dir1 dir? 'dir2 dir? or false ==) test.assert - ("systest" mkdir . ls (. "systest") => "/" join in?) test.assert + ("systest" mkdir pwd ls (pwd "systest") => "/" join in?) test.assert - ("systest" cd . "systest" match?) test.assert - .. cd + ("systest" cd pwd "systest" match?) test.assert + parent-dir cd ("./min -v" & 'output dget "\\." match?) test.assert@@ -48,20 +48,20 @@ ("test.txt" "test2.txt" cp "test2.txt" file?) test.assert
("test.txt" "test1.txt" mv "test1.txt" file?) test.assert - ("test2.txt" rm "test1.txt" rm . ls (. "test1.txt") => "/" join in? :t1 . ls "test2" in? t1 and false ==) test.assert + ("test2.txt" rm "test1.txt" rm pwd ls (pwd "test1.txt") => "/" join in? :t1 pwd ls "test2" in? t1 and false ==) test.assert ("systest" cd "TEST" "test.txt" fwrite "TEST1" "test1.txt" fwrite "TEST2" "test2.txt" fwrite "TEST3" "test3.txt" fwrite - . ls "test.zip" zip . ls (. "test.zip") => "/" join in?) test.assert + pwd ls "test.zip" zip pwd ls (pwd "test.zip") => "/" join in?) test.assert ("test.zip" "extracted" unzip "extracted" ls "extracted/test1.txt" in?) test.assert - .. cd + parent-dir cd - ("systest" rmdir . ls (. "systest") => "/" join in? false ==) test.assert + ("systest" rmdir pwd ls (pwd "systest") => "/" join in? false ==) test.assert ([ls] &ls /output ==) test.assert