@emartech/data-aggregator-language
Advanced tools
Comparing version 2.6.0 to 2.6.1
@@ -30,3 +30,3 @@ { | ||
}, | ||
"version": "2.6.0" | ||
"version": "2.6.1" | ||
} |
@@ -78,2 +78,14 @@ 'use strict'; | ||
}); | ||
it('works with a single negative number', () => { | ||
expect(aggregate('-5')).to.eql(-5); | ||
}); | ||
it('Subtraction with negative number', () => { | ||
expect(aggregate('5 - -5')).to.eql(10); | ||
}); | ||
it('should throw error when -- is used', () => { | ||
expect(() => aggregate('--5')).to.throw('Error parsing "--5"'); | ||
}); | ||
it('should work with positive number(with plus sign)', () => { | ||
expect(aggregate('+5')).to.eql(5); | ||
}); | ||
}); | ||
@@ -80,0 +92,0 @@ |
@@ -88,2 +88,5 @@ 'use strict'; | ||
numberExpression(ctx) { | ||
if (ctx.minusOperator) { | ||
return parseFloat(ctx.numberLiteral[0].image) * -1; | ||
} | ||
return parseFloat(ctx.numberLiteral[0].image); | ||
@@ -90,0 +93,0 @@ } |
@@ -133,2 +133,7 @@ 'use strict'; | ||
$.RULE('numberExpression', () => { | ||
$.OPTION(() => { | ||
$.OR([ | ||
{ ALT: () => $.CONSUME(minusOperator) }, | ||
{ ALT: () => $.CONSUME(plusOperator) }]); | ||
}); | ||
$.CONSUME(numberLiteral); | ||
@@ -135,0 +140,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28656
690