all repos — min @ 53bafb4271e43dc7435827082af6419865882b53

A small but practical concatenative programming language.

test(logic) Added tests for logic module.
h3rald h3rald@h3rald.com
Sun, 29 May 2016 20:03:05 +0200
commit

53bafb4271e43dc7435827082af6419865882b53

parent

790798c8a8fd4651ab41b2c9a52ebb3048079706

5 files changed, 144 insertions(+), 4 deletions(-)

jump to
M core/parser.nimcore/parser.nim

@@ -426,10 +426,12 @@ proc print*(a: MinValue) =

stdout.write($$a) proc `==`*(a: MinValue, b: MinValue): bool = - if a.kind == minInt and b.kind == minInt: + if a.kind == minSymbol and b.kind == minSymbol: + return a.symVal == b.symVal + elif a.kind == minInt and b.kind == minInt: return a.intVal == b.intVal elif a.kind == minInt and b.kind == minFloat: - return a.intVal.float == b.intVal.float + return a.intVal.float == b.floatVal.float elif a.kind == minFloat and b.kind == minFloat: return a.floatVal == b.floatVal elif a.kind == minFloat and b.kind == minInt:
M tests/all.mintests/all.min

@@ -1,2 +1,3 @@

@io @lang +@logic
M tests/lang.mintests/lang.min

@@ -3,7 +3,7 @@ #test

"lang" describe - (symbols size 154 ==) assert + (symbols size 153 ==) assert (sigils size 11 ==) assert
A tests/logic.min

@@ -0,0 +1,137 @@

+@test +#test + +"logic" describe + + (2 3 <) assert + (3 2 < false ==) assert + (3 3 < false ==) assert + (2.99 3 <) assert + (2 1.99 < false ==) assert + (1.99 1.991 <) assert + (1.99 1.990 < false ==) assert + ("test1" "test2" <) assert + ("test3" "test2" < false ==) assert + ("test2" "test2" < false ==) assert + + (2 3 <=) assert + (3 2 <= false ==) assert + (3 3 <=) assert + (2.99 3 <=) assert + (2 1.99 <= false ==) assert + (1.99 1.991 <=) assert + (1.99 1.990 <=) assert + ("test1" "test2" <=) assert + ("test3" "test2" <= false ==) assert + ("test2" "test2" <=) assert + + + (2 3 > false ==) assert + (3 2 >) assert + (3 3 > false ==) assert + (2.99 3 > false ==) assert + (2 1.99 >) assert + (1.99 1.991 > false ==) assert + (1.99 1.990 > false ==) assert + ("test1" "test2" > false ==) assert + ("test3" "test2" >) assert + ("test2" "test2" > false ==) assert + + (2 3 >= false ==) assert + (3 2 >=) assert + (3 3 >=) assert + (2.99 3 >= false ==) assert + (2 1.99 >=) assert + (1.99 1.991 >= false ==) assert + (1.99 1.990 >=) assert + ("test1" "test2" >= false ==) assert + ("test3" "test2" >=) assert + ("test2" "test2" >=) assert + + + (true true ==) assert + (false true == false ==) assert + (true false == false ==) assert + (false false ==) assert + (1 1 ==) assert + ("aaa" "aaa" ==) assert + (1.0 1 ==) assert + ((1 2 3.0) (1.0 2 3) ==) assert + (("a" "b") ("a" "b") ==) assert + (("a" "b" 3) ("a" "b" 4) == false ==) assert + ((1 "b" 3 myrandomsymbol) (1 "b" 3.0 myrandomsymbol) ==) assert + + (true true != false ==) assert + (false true !=) assert + (true false !=) assert + (false false != false ==) assert + (1 1 != false ==) assert + ("aaa" "aaa" != false ==) assert + (1.0 1 != false ==) assert + ((1 2 3.0) (1.0 2 3) != false ==) assert + (("a" "b") ("a" "b") != false ==) assert + (("a" "b" 3) ("a" "b" 4) !=) assert + ((1 "b" 3 myrandomsymbol) (1 "b" 3.0 myrandomsymbol) != false ==) assert + + (false not) assert + (true not false ==) assert + + (true true and) assert + (true false and false ==) assert + (false true and false ==) assert + (false false and false ==) assert + + (true true or) assert + (true false or) assert + (false true or) assert + (false false or false ==) assert + + (true true xor false ==) assert + (true false xor) assert + (false true xor) assert + (false false xor false ==) assert + + ("a" string?) assert + (1 string? false ==) assert + (1.0 string? false ==) assert + (true string? false ==) assert + (false string? false ==) assert + (("a" 2 c) string? false ==) assert + + ("a" int? false ==) assert + (1 int?) assert + (1.0 int? false ==) assert + (true int? false ==) assert + (false int? false ==) assert + (("a" 2 c) int? false ==) assert + + ("a" float? false ==) assert + (1 float? false ==) assert + (1.0 float?) assert + (true float? false ==) assert + (false float? false ==) assert + (("a" 2 c) float? false ==) assert + + ("a" bool? false ==) assert + (1 bool? false ==) assert + (1.0 bool? false ==) assert + (true bool?) assert + (false bool?) assert + (("a" 2 c) bool? false ==) assert + + ("a" number? false ==) assert + (1 number?) assert + (1.0 number?) assert + (true number? false ==) assert + (false number? false ==) assert + (("a" 2 c) number? false ==) assert + + ("a" quotation? false ==) assert + (1 quotation? false ==) assert + (1.0 quotation? false ==) assert + (true quotation? false ==) assert + (false quotation? false ==) assert + (("a" 2 c) quotation?) assert + + report + clear
M tests/test.mintests/test.min

@@ -1,6 +1,6 @@

;; test module ( - ("OK") ' .ok + 'OK ' .ok (" " print!) .padding ;; describe