From 495b2ac5abfdb1a75ad97277742fa44880834a12 Mon Sep 17 00:00:00 2001 From: s-ol Date: Sat, 1 May 2021 22:46:09 +0200 Subject: add thread-first/thread-last macro + spec --- spec/lang/thread_spec.moon | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 spec/lang/thread_spec.moon (limited to 'spec') diff --git a/spec/lang/thread_spec.moon b/spec/lang/thread_spec.moon new file mode 100644 index 0000000..aa30a1b --- /dev/null +++ b/spec/lang/thread_spec.moon @@ -0,0 +1,25 @@ +import TestPilot from require 'spec.test_setup' +import T, Struct, Array, Constant from require 'alv' + +describe "thread macros", -> + COPILOT = TestPilot '' + + it "thread forward (->)", -> + rt = COPILOT\eval_once ' + (import* math) + #((/ (+ 10 2) 2) = 6) + (-> 10 + (+ 2) + (/ 2))' + assert.is.true rt\is_const! + assert.is.equal (Constant.num 6), rt.result + + it "thread last forward (->>)", -> + rt = COPILOT\eval_once ' + (import* math) + #((/ 10 (+ 2 3)) = 2) + (->> 3 + (+ 2) + (/ 10))' + assert.is.true rt\is_const! + assert.is.equal (Constant.num 2), rt.result -- cgit v1.2.3