Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | var test = require('tape');
|
---|
2 | var Parser = require('../');
|
---|
3 |
|
---|
4 | var expected = [
|
---|
5 | [ [], '' ],
|
---|
6 | [ [], 'Hello' ],
|
---|
7 | [ [], 'This"is' ],
|
---|
8 | [ [], '\r\n\f\t\\/"' ],
|
---|
9 | [ [], 'Λάμβδα' ],
|
---|
10 | [ [], '\\' ],
|
---|
11 | [ [], '/' ],
|
---|
12 | [ [], '"' ],
|
---|
13 | [ [ 0 ], 0 ],
|
---|
14 | [ [ 1 ], 1 ],
|
---|
15 | [ [ 2 ], -1 ],
|
---|
16 | [ [], [ 0, 1, -1 ] ],
|
---|
17 | [ [ 0 ], 1 ],
|
---|
18 | [ [ 1 ], 1.1 ],
|
---|
19 | [ [ 2 ], -1.1 ],
|
---|
20 | [ [ 3 ], -1 ],
|
---|
21 | [ [], [ 1, 1.1, -1.1, -1 ] ],
|
---|
22 | [ [ 0 ], -1 ],
|
---|
23 | [ [], [ -1 ] ],
|
---|
24 | [ [ 0 ], -0.1 ],
|
---|
25 | [ [], [ -0.1 ] ],
|
---|
26 | [ [ 0 ], 6.02e+23 ],
|
---|
27 | [ [], [ 6.02e+23 ] ],
|
---|
28 | [ [ 0 ], '7161093205057351174' ],
|
---|
29 | [ [], [ '7161093205057351174'] ]
|
---|
30 | ];
|
---|
31 |
|
---|
32 | test('primitives', function (t) {
|
---|
33 | t.plan(25);
|
---|
34 |
|
---|
35 | var p = new Parser();
|
---|
36 | p.onValue = function (value) {
|
---|
37 | var keys = this.stack
|
---|
38 | .slice(1)
|
---|
39 | .map(function (item) { return item.key })
|
---|
40 | .concat(this.key !== undefined ? this.key : [])
|
---|
41 | ;
|
---|
42 | t.deepEqual(
|
---|
43 | [ keys, value ],
|
---|
44 | expected.shift()
|
---|
45 | );
|
---|
46 | };
|
---|
47 |
|
---|
48 | p.write('"""Hello""This\\"is""\\r\\n\\f\\t\\\\\\/\\""');
|
---|
49 | p.write('"\\u039b\\u03ac\\u03bc\\u03b2\\u03b4\\u03b1"');
|
---|
50 | p.write('"\\\\"');
|
---|
51 | p.write('"\\/"');
|
---|
52 | p.write('"\\""');
|
---|
53 | p.write('[0,1,-1]');
|
---|
54 | p.write('[1.0,1.1,-1.1,-1.0][-1][-0.1]');
|
---|
55 | p.write('[6.02e23]');
|
---|
56 | p.write('[7161093205057351174]');
|
---|
57 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.