aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-30 17:20:22 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-30 17:21:19 -0700
commitb53516c47c0dd1f9325f9f721f561487510cca98 (patch)
tree92961e19bc94eec3ab8b0f19357c57399c205b7d /tests
parent5637676bc45ce9aa3015726485f63a2a5745a45a (diff)
Simplified and correctified lib/object (though the codegen still need
streamlining), added a .stub member to Action trees, and switched Source's repr to be @filename[start:stop] instead of "filename[start:stop]"
Diffstat (limited to 'tests')
-rw-r--r--tests/object.nom33
1 files changed, 23 insertions, 10 deletions
diff --git a/tests/object.nom b/tests/object.nom
index 6433c86..aeeb559 100644
--- a/tests/object.nom
+++ b/tests/object.nom
@@ -1,16 +1,15 @@
use "core"
use "lib/object.nom"
-immediately
- object "Dog"
- action [bark]
- %barks <- ("Bark!" for % in 1 to ((me).barks))
- return: %barks joined with " "
+object "Dog"
+ action [bark]
+ %barks <- ("Bark!" for % in 1 to ((me).barks))
+ return: %barks joined with " "
- action [get pissed off]
- ((me).barks) +<- 1
+ action [get pissed off]
+ ((me).barks) +<- 1
-%d <-: new Dog {barks:2}
+%d <-: new "Dog" {barks:2}
as %d
assume: (me) = %d
assume: ((me).barks) = 2
@@ -18,10 +17,24 @@ as %d
get pissed off
assume: ((me).barks) = 3
assume: (bark) = "Bark! Bark! Bark!"
-assume: "\(%d's "class")" = "Dog"
+assume: "\(%d.class)" = "Dog"
assume: (%d's "barks") = 3
-as: new Dog {barks:1}
+as: new "Dog" {barks:1}
assume: (bark) = "Bark!"
+action [foo]
+ as: new "Dog" {barks:23}
+ return: (me).barks
+ barf "Reached unreachable code"
+
+assume: (foo) = 23
+
+as: new "Dog" {barks:101}
+ try: as (new "Dog" {barks:8}) (barf)
+ ..and if it succeeds: barf
+
+ assume: (me).barks = 101
+ ..or barf "Error in nested 'as % %' failed to properly reset 'self'"
+
say "Object test passed."