File tree 2 files changed +16
-10
lines changed
2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -284,17 +284,11 @@ describe('Test expressions', function() {
284
284
285
285
var cExpr = ast . children [ 2 ] . right ;
286
286
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 ( '/' ) ;
288
290
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' ) ;
298
292
299
293
var dExpr = ast . children [ 3 ] . right ;
300
294
dExpr . should . have . property ( 'kind' , 'bin' ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ var parser = require('../src/index');
7
7
var checkPrecedence = function ( a , b ) {
8
8
if ( ! a || ! b ) return false ;
9
9
if ( b . kind === 'parenthesis' ) {
10
+ // force the precendence with parenthesis
11
+ // ignore them in test
10
12
b = b . inner ;
11
13
}
12
14
for ( var k in b ) {
@@ -106,5 +108,15 @@ describe('Test precedence', function() {
106
108
shouldBeSame ( '!4 instanceof 3' , '(!4) instanceof 3' ) ;
107
109
shouldBeSame ( '!4 + 5 instanceof 3' , '(!4) + (5 instanceof 3)' ) ;
108
110
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)' ) ;
109
121
} ) ;
110
122
} ) ;
You can’t perform that action at this time.
0 commit comments