File: json.liq

package info (click to toggle)
liquidsoap 1.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,504 kB
  • sloc: ml: 37,149; python: 956; makefile: 624; sh: 458; perl: 322; lisp: 124; ansic: 53; ruby: 8
file content (30 lines) | stat: -rw-r--r-- 571 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
# We test some ground values for json import/export.

%include "test.liq"

success = ref true

def test(d,x) =
  y = of_json(default=d,json_of(x))
  if y == d or y != x then
    success := false
  end
end

test(2, 1)
test(3.14, 4.25)
test(false, true)
test("abc", "def")
test([],[1,2,3])
test((1,"foo"), (2,"bar"))
test([("foo",(1,"bar"))], [("gni",(2,"boo"))])
test([(1,[("fr","bar")])], [(2,[("en","foo")])])
test([("ping",())], [("pong",())])
test([3],[])
test([("x",0)],of_json(default=[("x",0)],"{\"a\" : 4}"))

if !success then
  test.pass()
else
  test.fail()
end