it('should parse negative floats', () => {
            let literal = Parser.parse('-1.1', { type });
            expect(literal.output.getType()).to.equal(Scalar.Type.V_FLOAT);
            expect(literal.output.getVFloat()).to.equal(-1.1);

            literal = Parser.parse('-1.1111111', { type });
            expect(literal.output.getType()).to.equal(Scalar.Type.V_FLOAT);
            expect(literal.output.getVFloat()).to.equal(-1.1111111);
        });
        it('should parse booleans', () => {
            let literal = Parser.parse('true', { type });
            expect(literal.output.getType()).to.equal(Scalar.Type.V_BOOL);
            expect(literal.output.getVBool()).to.equal(true);

            literal = Parser.parse('false', { type });
            expect(literal.output.getType()).to.equal(Scalar.Type.V_BOOL);
            expect(literal.output.getVBool()).to.equal(false);
        });
        it('should not loose precision for big numbers', () => {
            let overflow = Number.MAX_SAFE_INTEGER + 1;
            let literal = Parser.parse(`${overflow}`, { type });
            expect(literal.output.getType()).to.equal(Scalar.Type.V_STRING);
            /* eslint-disable node/no-deprecated-api */
            expect(new Buffer(literal.output.getVString().getValue()).toString()).to.equal(`${overflow}`);
            /* eslint-enable node/no-deprecated-api */

            overflow = Number.MIN_SAFE_INTEGER - 1;
            literal = Parser.parse(`${overflow}`, { type });
            expect(literal.output.getType()).to.equal(Scalar.Type.V_STRING);
            /* eslint-disable node/no-deprecated-api */
            expect(new Buffer(literal.output.getVString().getValue()).toString()).to.equal(`${overflow}`);
            /* eslint-enable node/no-deprecated-api */
        });
 it('should parse single-quoted strings', () => {
     const literal = Parser.parse("'bar'", { type });
     expect(literal.output.getType()).to.equal(Scalar.Type.V_STRING);
     /* eslint-disable node/no-deprecated-api */
     expect(new Buffer(literal.output.getVString().getValue()).toString()).to.equal('bar');
     /* eslint-enable node/no-deprecated-api */
 });
Example #5
0
 expect(() => Parser.parse("doc->'$.foo'")).to.throw();
Example #6
0
 expect(() => Parser.parse('[<"foo", 1>]')).to.throw();
Example #7
0
 expect(() => Parser.parse('$**.bar()')).to.throw();
Example #8
0
 expect(() => Parser.parse('foo[*]."bar"')).to.throw();
Example #9
0
 expect(() => Parser.parse('$.**')).to.throw();
Example #10
0
 expect(() => Parser.parse('_**[*]_.**._')).to.throw();
Example #11
0
 expect(() => Parser.parse('$.a[*].z', options)).to.throw();
Example #12
0
 expect(() => Parser.parse('$.a[0].b[0]', options)).to.throw();
Example #13
0
 expect(() => Parser.parse('$ = {"a":1}', options)).to.throw();
Example #14
0
 expect(() => Parser.parse('$.foo.bar[*]', options)).to.throw();
Example #15
0
 expect(() => Parser.parse('_**[*]._**._', options)).to.throw();
Example #16
0
 expect(() => Parser.parse('.doc')).to.throw();
Example #17
0
 expect(() => Parser.parse('**foo')).to.throw();
Example #18
0
 expect(() => Parser.parse('$."foo bar"."baz**" = $', options)).to.throw();
Example #19
0
 expect(() => Parser.parse('$.foo[**]')).to.throw();
Example #20
0
 expect(() => Parser.parse('$.foo**.bar', options)).to.throw();
Example #21
0
 expect(() => Parser.parse('$.foo..bar')).to.throw();
Example #22
0
 expect(() => Parser.parse('$."foo bar"**.baz', options)).to.throw();
Example #23
0
 expect(() => Parser.parse('"foo".bar')).to.throw();
Example #24
0
 expect(() => Parser.parse('$."foo."**.".bar"', options)).to.throw();
Example #25
0
 expect(() => Parser.parse('[<foo, bar>]')).to.throw();
Example #26
0
 expect(() => Parser.parse('$.""', options)).to.throw();
Example #27
0
 expect(() => Parser.parse('{<foobar>}')).to.throw();
Example #28
0
 expect(() => Parser.parse('$**[0]', options)).to.throw();
Example #29
0
 expect(() => Parser.parse("foo.bar->'$.foo'")).to.throw();
Example #30
0
 expect(() => Parser.parse('$.a**.foo', options)).to.throw();