aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-14 22:46:54 -0500
committerJoel Martin <github@martintribe.org>2014-04-14 22:46:54 -0500
commit0027e8fed423a24ec93234a6bf0fb701c233d583 (patch)
treec1c447a16958fc174f15af15c181b1582506d9ed /tests
parent8adb082743f12402d0817018ab1e8ff0c0e4729e (diff)
downloadmal-0027e8fed423a24ec93234a6bf0fb701c233d583.tar.gz
mal-0027e8fed423a24ec93234a6bf0fb701c233d583.zip
PS: fix function closures. Self-hosted up to step7.
Diffstat (limited to 'tests')
-rw-r--r--tests/incB.mal3
-rw-r--r--tests/step4_if_fn_do.mal3
-rw-r--r--tests/stepA_more.mal15
3 files changed, 21 insertions, 0 deletions
diff --git a/tests/incB.mal b/tests/incB.mal
index ed28734..86960c5 100644
--- a/tests/incB.mal
+++ b/tests/incB.mal
@@ -12,3 +12,6 @@
(prn "incB.mal finished")
"incB.mal return string"
+
+;; ending comment
+
diff --git a/tests/step4_if_fn_do.mal b/tests/step4_if_fn_do.mal
index a4ce46f..4d41380 100644
--- a/tests/step4_if_fn_do.mal
+++ b/tests/step4_if_fn_do.mal
@@ -264,6 +264,9 @@
( (fn* () 4) )
;=>4
+( (fn* (f x) (f x)) (fn* (a) (+ 1 a)) 7)
+;=>8
+
;; Testing closures
( ( (fn* (a) (fn* (b) (+ a b))) 5) 7)
diff --git a/tests/stepA_more.mal b/tests/stepA_more.mal
index f6b01f5..892b592 100644
--- a/tests/stepA_more.mal
+++ b/tests/stepA_more.mal
@@ -117,6 +117,9 @@
(map? [])
;=>false
+(get nil "a")
+;=>nil
+
(get hm1 "a")
;=>nil
@@ -174,6 +177,9 @@
(meta (fn* (a) a))
;=>nil
+(meta +)
+;=>nil
+
(with-meta [1 2 3] {"a" 1})
;=>[1 2 3]
@@ -276,6 +282,15 @@
(swap! a + 3)
;=>123
+;; Testing swap!/closure interaction
+(def! inc-it (fn* (a) (+ 1 a)))
+(def! atm (atom 7))
+(def! f (fn* [] (swap! atm inc-it)))
+(f)
+;=>8
+(f)
+;=>9
+
;;
;; Testing read-str and eval
(read-string "(1 2 (3 4) nil)")