• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/lighttpd-1.4.39/external_file/js/davclient.js/jsbase/
1load('string.js');
2load('misclib.js');
3
4function test_repr() {
5    var b = true;
6    testing.assertEquals(misclib.repr(b), 'true');
7
8    var n = 10;
9    testing.assertEquals(misclib.repr(n), '10');
10
11    var s = 'foo';
12    testing.assertEquals(misclib.repr(s), '"foo"');
13
14    var s2 = 'foo\\bar';
15    testing.assertEquals(misclib.repr(s2), '"foo\\\\bar"');
16
17    var a = [false, 1, '2'];
18    testing.assertEquals(misclib.repr(a), '[false, 1, "2"]');
19
20    var d = new Date(1234567);
21    testing.assertEquals(misclib.repr(d), '(new Date(1234567))');
22
23    var o = {foo: [1,2,3],
24                bar: {foo: true}};
25    testing.assertEquals(misclib.repr(o), '{foo: [1, 2, 3], bar: {foo: true}}');
26
27    var f = {};
28    f.f = f;
29    testing.assertThrows(undefined, misclib.repr, misclib, f, true);
30};
31
32function test_safe_repr() {
33    var f = {};
34    testing.assertEquals(misclib.safe_repr(f), '#0={}');
35
36    f.foo = f;
37    testing.assertEquals(misclib.safe_repr(f), '#0={foo: #0#}');
38
39    f.bar = {};
40    testing.assertEquals(misclib.safe_repr(f), '#0={foo: #0#, bar: #1={}}');
41
42    f.bar.f = f;
43    testing.assertEquals(misclib.safe_repr(f), '#0={foo: #0#, bar: #1={f: #0#}}');
44
45    f.bar = [];
46    testing.assertEquals(misclib.safe_repr(f), '#0={foo: #0#, bar: #1=[]}');
47
48    f.bar[0] = f;
49    testing.assertEquals(misclib.safe_repr(f), '#0={foo: #0#, bar: #1=[#0#]}');
50};
51