test(sys) Added tests for sys module.
h3rald h3rald@h3rald.com
Fri, 03 Jun 2016 13:00:59 +0200
6 files changed,
45 insertions(+),
6 deletions(-)
M
lib/lang.nim
→
lib/lang.nim
@@ -268,10 +268,12 @@ i.error errIncorrect, "An integer and a quotation are required on the stack"
.symbol("size") do (i: In): let q = i.pop - if not q.isQuotation: - i.error errNoQuotation - return - i.push q.qVal.len.newVal + if q.isQuotation: + i.push q.qVal.len.newVal + elif q.isString: + i.push q.strVal.len.newVal + else: + i.error(errIncorrect, "A quotation or a string is required on the stack") .symbol("contains") do (i: In): let v = i.pop
M
lib/prelude.min
→
lib/prelude.min
@@ -44,6 +44,7 @@ 'scope :=>
'filter :select 'clear :empty 'cons :prepend +'size :length ; Mathematical Operators (1 +) :succ
M
lib/sys.nim
→
lib/sys.nim
@@ -62,8 +62,8 @@ else:
i.error(errIncorrect, "A string is required on the stack") .symbol("putenv") do (i: In): - let value = i.pop let key = i.pop + let value = i.pop if value.isString and key.isString: key.strVal.putEnv value.strVal else:
M
tests/lang.min
→
tests/lang.min
@@ -3,7 +3,7 @@ #test
"lang" describe - (symbols size 156 ==) assert + (symbols size 157 ==) assert (sigils size 10 ==) assert
A
tests/sys.min
@@ -0,0 +1,35 @@
+@test +#test + +"sys" describe + + ("systest" mkdir "." ls "./systest" contains) assert + + ("systest" cd pwd "systest" match) assert + ".." cd + + (&ls "\n" split "systest" contains) assert + + ($PATH length 0 >) assert + + ("TEST" "AAA" putenv $AAA "TEST" ==) assert + + (os length 0 >) assert + + (cpu length 0 >) assert + + ("TEST" "test.txt" fwrite "test.txt" file?) assert + + ("systest" dir?) assert + + ("test.txt" "test2.txt" cp "test2.txt" file?) assert + + ("test.txt" "test1.txt" mv "test1.txt" file?) assert + + ("test2.txt" rm "test1.txt" rm pwd ls "test1.txt" contains :t1 pwd ls "test2" contains t1 and false ==) assert + + ("systest" rmdir pwd ls "systest" contains false ==) assert + + report + clear + "systest" rmdir