aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test/test/lux/host.js.lux
blob: f533a8fe60d8cc638c17b2e26757cce50e44c968 (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
25
26
27
28
29
30
31
(;module:
  lux
  (lux [io]
       (control monad)
       (data text/format)
       ["&" host]
       ["R" math/random])
  lux/test)

(context: "JavaScript operations"
  ($_ seq
      (test "Null equals itself."
            (is (&;null) (&;null)))

      (test "Undefined equals itself."
            (is (&;undef) (&;undef)))

      (test "Can reference JavaScript objects."
            (is (&;ref "Math") (&;ref "Math")))

      (test "Can create objects and access their fields."
            (|> (&;object "foo" "BAR")
                (&;get "foo" Text)
                (is "BAR")))

      (test "Can call JavaScript functions"
            (and (is 124.0
                     (&;call! (&;ref "Math.ceil" &;Function) [123.45] Real))
                 (is 124.0
                     (&;call! (&;ref "Math") "ceil" [123.45] Real))))
      ))