release 0.1.0
This commit is contained in:
commit
30d94536a9
90 changed files with 7722 additions and 0 deletions
78
modules/core/tests/scope.owa
Normal file
78
modules/core/tests/scope.owa
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
(namespace tests.scopes
|
||||
(test.case "def"
|
||||
(def x 1)
|
||||
(assert.eq! x 1)
|
||||
|
||||
(def [y z] [1 2])
|
||||
(assert.eq! y 1)
|
||||
(assert.eq! z 2)
|
||||
)
|
||||
|
||||
(test.case "def bounded"
|
||||
(def x 1)
|
||||
(try
|
||||
(def x 2)
|
||||
(catch :Panic (return))
|
||||
)
|
||||
(unreachable!)
|
||||
)
|
||||
|
||||
(test.case "set!"
|
||||
(def [x y] [1 1])
|
||||
(set! x 2)
|
||||
(assert.eq! x 2)
|
||||
|
||||
(set! [x y] [3 4])
|
||||
(assert.eq! x 3)
|
||||
(assert.eq! y 4)
|
||||
)
|
||||
|
||||
(test.case "set! unbounded"
|
||||
(try
|
||||
(set! x 2)
|
||||
(catch :UnboundVariable (return))
|
||||
)
|
||||
(unreachable!)
|
||||
)
|
||||
|
||||
(test.case "lookup"
|
||||
(def x 1)
|
||||
(assert.eq! (lookup x null) 1)
|
||||
(assert.eq! (lookup y null) null)
|
||||
)
|
||||
|
||||
(test.case "inheritance"
|
||||
(scope
|
||||
(def x 1)
|
||||
(scope
|
||||
(assert.eq! x 1)
|
||||
(set! x 2)
|
||||
)
|
||||
(assert.eq! x 2)
|
||||
)
|
||||
)
|
||||
|
||||
(test.case "shadowing"
|
||||
(scope
|
||||
(def x 100)
|
||||
(scope
|
||||
(def x 1)
|
||||
)
|
||||
(assert.eq! x 100)
|
||||
)
|
||||
(assert.eq! (lookup x null) null)
|
||||
)
|
||||
|
||||
(test.case "leakage"
|
||||
(scope (def x 1))
|
||||
(assert.eq! (lookup x null) null)
|
||||
|
||||
(scope (def y 2))
|
||||
(assert.eq! (lookup y null) null)
|
||||
|
||||
(scope
|
||||
(scope (def z 1))
|
||||
(assert.eq! (lookup z null) null)
|
||||
)
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue