aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/host.js.lux
blob: faf9f6b5ffb45d2e0345ff3ee07973f5dfad79a1 (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
(.module:
  [lux #*
   ["&" host]
   [math ["r" 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] Frac))
                 (is? +124.0
                      (&.call! (&.ref "Math") "ceil" [+123.45] Frac))))
      ))