aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2017-12-31 23:51:33 -0400
committerEduardo Julian2017-12-31 23:51:33 -0400
commit232f9e7a167cec04216bdaa2071ecdb20a1fd03c (patch)
treee35ab67eba0c3669f00709355c4cb1bda56791a2 /stdlib/test
parent8f071917892ac919b91da12c2bf02d5d9b79f81a (diff)
- Added safe (single-threaded) mutation.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/control/thread.lux20
-rw-r--r--stdlib/test/tests.lux3
2 files changed, 22 insertions, 1 deletions
diff --git a/stdlib/test/test/lux/control/thread.lux b/stdlib/test/test/lux/control/thread.lux
new file mode 100644
index 000000000..3dd27d0ad
--- /dev/null
+++ b/stdlib/test/test/lux/control/thread.lux
@@ -0,0 +1,20 @@
+(.module:
+ lux
+ (lux (control [monad #+ do]
+ ["/" thread])))
+
+(def: _test0_
+ Nat
+ (/.run (do /.Monad<Thread>
+ [box (/.box +123)
+ old (/.update (n/* +2) box)
+ new (/.read box)]
+ (wrap (n/+ old new)))))
+
+(def: _test1_
+ (All [!] (/.Thread ! Nat))
+ (do /.Monad<Thread>
+ [box (/.box +123)
+ old (/.update (n/* +2) box)
+ new (/.read box)]
+ (wrap (n/+ old new))))
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index ecce3d56b..87f9c913d 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -21,7 +21,8 @@
["_." reader]
["_." writer]
["_." state]
- ["_." parser])
+ ["_." parser]
+ ["_." thread])
(data ["_." bit]
["_." bool]
["_." error]