Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/src/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ class ExpressionParser {
'!=': 6,
'<=': 7,
'>=': 7,
'<': 7,
'>': 7,
// must be before '<' to prevent the parser from prematurely accepting it as the shorter operator
'<<': 8,
// must be before '>' to prevent the parser from prematurely accepting it as the shorter operator
'>>': 8,
'<': 7,
'>': 7,
'+': 9,
'-': 9,
'*': 10,
Expand Down
9 changes: 7 additions & 2 deletions test/expressions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ void main() {
'1+2',
'a+b*2-Math.sqrt(2)',
'-1+2',
'1+4-5%2*5<4==(2+1)*1<=2&&2||2'
'1+4-5%2*5<4==(2+1)*1<=2&&2||2',
'1<<10',
'4>>5',
'2^4~/3>=x??4'
]) {
var w = parser.binaryExpression.end().parse(v);
expect(w is Success, isTrue, reason: 'Failed parsing `$v`');
Expand Down Expand Up @@ -188,10 +191,12 @@ void main() {
'x*x+y*y==z*z': true,
'n ?? 1': 1,
'5~/2': 2,
'4<<5<100>>1<<2': true,
};

expressions.forEach((e, r) {
expect(evaluator.eval(Expression.parse(e), context), r);
expect(evaluator.eval(Expression.parse(e), context), r,
reason: 'Failed evaluating `$e`');
});
});
test('index expressions', () {
Expand Down