aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lang/thread_spec.moon
blob: 9e84575e7e12756d0538158a6899cb3a110ae5f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import TestPilot from require 'spec.test_setup'

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 '<num= 6.0>', tostring 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 '<num= 2.0>', tostring rt.result