summaryrefslogtreecommitdiff
path: root/tests/itjs.t
blob: ef3437ab58ebca0090af4367dfc55d3a3c8ea287 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/www/server/bin/php -qC
<?php

# Tests for itjs.class, currently only itjs::serialize()

require 'searchlib/search_test.class';

is(
	itjs::serialize(array()),
	'[]',
	'empty array'
);

is(
	itjs::serialize(array(0, "0")),
	'[0, 0]',
	'number 0'
);

is(
	itjs::serialize(array(null, "", false)),
	'["", "", false]',
	'null, empty string, false'
);

is(
	itjs::serialize(array(42, "42", 42.5, "042")),
	'[42, 42, "42.5", "042"]',
	'numbers'
);

is(
	itjs::serialize(array('foo' => "bar", "qux", 42 => "quux")),
	"{foo:\"bar\",\n'0':\"qux\",\n'42':\"quux\"}",
	'key-value pairs'
);

is(
	itjs::serialize(array('foo' => array('bar' => array("qux", 42)))),
	'{foo:{bar:["qux", 42]}}',
	'nested arrays'
);

is(
	itjs::serialize(array('import' => array('function' => array(true, 42)))),
	'{\'import\':{\'function\':[true, 42]}}',
	'keywords'
);

?>