Skip to content

Commit 3c8901f

Browse files
committed
glayzzle#75 update tests
1 parent bbdbf59 commit 3c8901f

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

test/exprTests.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,11 @@ describe('Test expressions', function() {
284284

285285
var cExpr = ast.children[2].right;
286286
cExpr.kind.should.be.exactly('bin');
287-
cExpr.left.value.should.be.exactly('1');
287+
cExpr.left.type.should.be.exactly('+');
288+
cExpr.left.left.value.should.be.exactly('1');
289+
cExpr.left.right.type.should.be.exactly('/');
288290
cExpr.type.should.be.exactly('+');
289-
290-
cExpr.right.kind.should.be.exactly('bin');
291-
cExpr.right.right.value.should.be.exactly('4');
292-
cExpr.right.type.should.be.exactly('+');
293-
294-
cExpr.right.left.kind.should.be.exactly('bin');
295-
cExpr.right.left.left.value.should.be.exactly('2');
296-
cExpr.right.left.type.should.be.exactly('/');
297-
cExpr.right.left.right.value.should.be.exactly('3');
291+
cExpr.right.value.should.be.exactly('4');
298292

299293
var dExpr = ast.children[3].right;
300294
dExpr.should.have.property('kind', 'bin');

test/precedence.js

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var parser = require('../src/index');
77
var checkPrecedence = function(a, b) {
88
if (!a || !b) return false;
99
if (b.kind === 'parenthesis') {
10+
// force the precendence with parenthesis
11+
// ignore them in test
1012
b = b.inner;
1113
}
1214
for(var k in b) {
@@ -106,5 +108,15 @@ describe('Test precedence', function() {
106108
shouldBeSame('!4 instanceof 3', '(!4) instanceof 3');
107109
shouldBeSame('!4 + 5 instanceof 3', '(!4) + (5 instanceof 3)');
108110
shouldBeSame('6 + !4 + 5', '6 + (!4) + 5');
111+
shouldBeSame('if($a && !$b) {}', 'if($a && (!$b)) {}');
112+
});
113+
it('test concat', function() {
114+
shouldBeSame('"a"."b"."c"."d"', '((("a"."b")."c")."d")');
115+
});
116+
it('test retif', function() {
117+
shouldBeSame('$a ? 1 : $b ? 2 : $c ? 3 : 4', '(($a ? 1 : $b) ? 2 : $c) ? 3 : 4');
118+
});
119+
it('test + / *', function() {
120+
shouldBeSame('1 + 2 * 3', '1 + (2 * 3)');
109121
});
110122
});

0 commit comments

Comments
 (0)