node_modules/jsonparse/test/primitives.js

Maintainability

71.76

Lines of code

54

Created with Raphaël 2.1.002550751002015-1-52014-12-42014-12-3

2015-5-18
Maintainability: 71.76

Created with Raphaël 2.1.00153045602015-1-52014-12-42014-12-3

2015-5-18
Lines of Code: 54

Difficulty

17.73

Estimated Errors

0.54

Function weight

By Complexity

Created with Raphaël 2.1.0p.onValue2

By SLOC

Created with Raphaël 2.1.0<anonymous>25
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.019999999999999e+23 ],
27
  [ [], [ 6.019999999999999e+23 ] ]
28
];
29
 
30
test('primitives', function (t) {
31
  t.plan(23);
32
 
33
  var p = new Parser();
34
  p.onValue = function (value) {
35
    var keys = this.stack
36
      .slice(1)
37
      .map(function (item) { return item.key })
Column: 45 "Missing semicolon."
38
      .concat(this.key !== undefined ? this.key : [])
39
    ;
40
    t.deepEqual(
41
      [ keys, value ],
42
      expected.shift()
43
    );
44
  };
45
 
46
  p.write('"""Hello""This\\"is""\\r\\n\\f\\t\\\\\\/\\""');
47
  p.write('"\\u039b\\u03ac\\u03bc\\u03b2\\u03b4\\u03b1"');
48
  p.write('"\\\\"');
49
  p.write('"\\/"');
50
  p.write('"\\""');
51
  p.write('[0,1,-1]');
52
  p.write('[1.0,1.1,-1.1,-1.0][-1][-0.1]');
53
  p.write('[6.02e23]');
54
});