diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/collections.nom | 2 | ||||
| -rw-r--r-- | tests/metaprogramming.nom | 8 | ||||
| -rw-r--r-- | tests/object.nom | 37 | ||||
| -rw-r--r-- | tests/operators.nom | 16 |
4 files changed, 32 insertions, 31 deletions
diff --git a/tests/collections.nom b/tests/collections.nom index 855baea..60b2d25 100644 --- a/tests/collections.nom +++ b/tests/collections.nom @@ -11,7 +11,7 @@ assume (99 isn't in [1,2,3]) assume ({x:no} has key "x") assume ({x:no} doesn't have key "y") assume (not ({x:no} doesn't have key "x")) -assume ((size of [1,2,3]) = 3) +assume ((length of [1,2,3]) = 3) %list <- [1,2,3,4,5] append 6 to %list assume ((last in %list) = 6) diff --git a/tests/metaprogramming.nom b/tests/metaprogramming.nom index 360771e..c6aa719 100644 --- a/tests/metaprogramming.nom +++ b/tests/metaprogramming.nom @@ -4,11 +4,11 @@ use "core" immediately - compile [five] to {expr:"5"} + compile [five] to: Lua value "5" assume ((five) = 5) or barf "Compile to expression failed." immediately - compile [loc x] to {statements:"_x = 99", locals:["_x"]} + compile [loc x] to: Lua "local _x = 99;" lua> "do" loc x assume (%x is 99) or barf "Compile to statements with locals failed." @@ -18,7 +18,7 @@ assume (%x is (nil)) or barf "Failed to properly localize a variable." immediately compile [asdf] to %tmp <- "" - return {statements:%tmp} + return: Lua %tmp asdf assume (%tmp is (nil)) or barf "compile to is leaking variables" @@ -42,7 +42,7 @@ try: foo 99 assume ((\(5 + 5) as value) = 10) or barf "%tree as value failed." -assume ((\(foo %x)'s source code) = "foo %x") or barf "source code failed." +assume (((\(foo %x)'s source code) as text) = "foo %x") or barf "source code failed." assume ((repr [1,2]) = "{1, 2}") or barf "repr failed." diff --git a/tests/object.nom b/tests/object.nom index 84524e5..ab87fc7 100644 --- a/tests/object.nom +++ b/tests/object.nom @@ -1,23 +1,24 @@ use "core" use "lib/object2.nom" -immediately: - define object "Dog": - action [bark]: - %barks <- ("Bark!" for all 1 to (@%barks)) - return (%barks joined with " ") - action [get pissed off]: - (@%barks) +<- 1 +#.. + immediately: + define object "Dog": + action [bark]: + %barks <- ("Bark!" for all 1 to (@%barks)) + return (%barks joined with " ") + action [get pissed off]: + (@%barks) +<- 1 -%d <- (new Dog {barks:2}) -as %d: - assume ((@) = %d) - assume ((@%barks) = 2) - assume ((bark) = "Bark! Bark!") - get pissed off - assume ((@%barks) = 3) - assume ((bark) = "Bark! Bark! Bark!") -assume ("\(%d's "class")" = "Dog") -assume ((%d's "barks") = 3) + %d <- (new Dog {barks:2}) + as %d: + assume ((@) = %d) + assume ((@%barks) = 2) + assume ((bark) = "Bark! Bark!") + get pissed off + assume ((@%barks) = 3) + assume ((bark) = "Bark! Bark! Bark!") + assume ("\(%d's "class")" = "Dog") + assume ((%d's "barks") = 3) -say "Object test passed." + say "Object test passed." diff --git a/tests/operators.nom b/tests/operators.nom index 1a138cb..40c503f 100644 --- a/tests/operators.nom +++ b/tests/operators.nom @@ -17,23 +17,23 @@ assume ((%y = 10) and (%x = 20)) or barf "swapping vars failed." assume ({} is {}) or barf "Equality check failed." assume (({}'s id) is not ({}'s id)) or barf "Identity check failed." -<-{%x:"outer",%y:"outer"} +<-{%foozle:"outer",%y:"outer"} action [set global x local y] - export %x <- "inner" + export %foozle <- "inner" %y <- "inner" set global x local y -assume ((%x = "inner") and (%y = "outer")) or barf "export failed." +assume ((%foozle = "inner") and (%y = "outer")) or barf "export failed." -<-{%x:"outer",%y:"outer"} +<-{%foozle:"outer",%y:"outer"} action [set global x local y] - exporting [%x] - %x <- "inner" + exporting [%foozle] + %foozle <- "inner" %y <- "inner" set global x local y -assume ((%x = "inner") and (%y = "outer")) or barf "export failed." +assume ((%foozle = "inner") and (%y = "outer")) or barf "exporting failed." <-{%x:1,%y:2} -with [%z, %x<-999] +with {%z:nil, %x:999} %z <- 999 assume (%z = 999) or barf "'with' failed." assume (%x = 999) or barf "'with' assignment failed." |
