File: null.liq

package info (click to toggle)
liquidsoap 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,372 kB
  • sloc: ml: 71,806; javascript: 27,320; ansic: 398; xml: 114; sh: 99; lisp: 96; makefile: 26
file content (39 lines) | stat: -rw-r--r-- 763 bytes parent folder | download
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
32
33
34
35
36
37
38
39
def f() =
  test.equal(null ?? "bla", "bla")
  test.equal(null("foo") ?? "bla", "foo")
  test.equal(null.case(null, {true}, fun (_) -> false), true)
  test.equal(null.case("x", {true}, fun (_) -> false), false)
  test.equal(null.get("x"), "x")
  test.equal(null.get(default="x", "y"), "y")
  test.equal(null.get(default="x", null), "x")
  test.equal(
    null.find(
      fun (x) -> if x mod 2 == 0 then 2 * x else null end,
      [1, 3, 2, 5]
    ),
    4
  )

  def f((x:int?)) =
    if true then 1 else x end
  end

  def g() =
    if true then null else (1 : int?) end
  end

  # Subtyping
  def f() =
    if true then null else 1 end
  end

  def f() =
    if true then 1 else null end
  end

  _ = [null, 3]
  _ = [3, null]
  test.pass()
end

test.check(f)