2015-08-06 19:27:46 +00:00
new _statement : {
input : {
new x ( 1 ) ;
new x ( 1 ) ( 2 ) ;
new x ( 1 ) ( 2 ) ( 3 ) ;
new new x ( 1 ) ;
new new x ( 1 ) ( 2 ) ;
new ( new x ( 1 ) ) ( 2 ) ;
( new new x ( 1 ) ) ( 2 ) ;
}
expect _exact : "new x(1);new x(1)(2);new x(1)(2)(3);new new x(1);new new x(1)(2);new new x(1)(2);(new new x(1))(2);"
}
2016-06-06 23:33:13 +00:00
2016-06-10 13:42:55 +00:00
new _statements _2 : {
input : {
new x ;
new new x ;
new new new x ;
new true ;
new ( 0 ) ;
new ( ! 0 ) ;
new ( bar = function ( foo ) { this . foo = foo ; } ) ( 123 ) ;
new ( bar = function ( foo ) { this . foo = foo ; } ) ( ) ;
}
expect _exact : "new x;new(new x);new(new(new x));new true;new 0;new(!0);new(bar=function(foo){this.foo=foo})(123);new(bar=function(foo){this.foo=foo});"
}
new _statements _3 : {
input : {
new ( function ( foo ) { this . foo = foo ; } ) ( 1 ) ;
new ( function ( foo ) { this . foo = foo ; } ) ( ) ;
new ( function test ( foo ) { this . foo = foo ; } ) ( 1 ) ;
new ( function test ( foo ) { this . foo = foo ; } ) ( ) ;
}
expect _exact : "new function(foo){this.foo=foo}(1);new function(foo){this.foo=foo};new function test(foo){this.foo=foo}(1);new function test(foo){this.foo=foo};"
}
2016-06-06 23:33:13 +00:00
new _with _rewritten _true _value : {
options = { booleans : true }
input : {
new true ;
}
expect _exact : "new(!0);"
}
2016-06-10 13:42:55 +00:00
new _with _many _parameters : {
input : {
new foo . bar ( "baz" ) ;
new x ( /123/ , 456 ) ;
}
expect _exact : 'new foo.bar("baz");new x(/123/,456);'
}
2016-07-23 15:50:44 +00:00
new _constructor _with _unary _arguments : {
input : {
new x ( ) ;
new x ( - 1 ) ;
new x ( - 1 , - 2 ) ;
new x ( void 1 , + 2 , - 3 , ~ 4 , ! 5 , -- a , ++ b , c -- , d ++ , typeof e , delete f ) ;
new ( - 1 ) ; // should parse despite being invalid at runtime.
new ( - 1 ) ( ) ; // should parse despite being invalid at runtime.
new ( - 1 ) ( - 2 ) ; // should parse despite being invalid at runtime.
}
expect _exact : "new x;new x(-1);new x(-1,-2);new x(void 1,+2,-3,~4,!5,--a,++b,c--,d++,typeof e,delete f);new(-1);new(-1);new(-1)(-2);"
}
call _with _unary _arguments : {
input : {
x ( ) ;
x ( - 1 ) ;
x ( - 1 , - 2 ) ;
x ( void 1 , + 2 , - 3 , ~ 4 , ! 5 , -- a , ++ b , c -- , d ++ , typeof e , delete f ) ;
( - 1 ) ( ) ; // should parse despite being invalid at runtime.
( - 1 ) ( - 2 ) ; // should parse despite being invalid at runtime.
}
expect _exact : "x();x(-1);x(-1,-2);x(void 1,+2,-3,~4,!5,--a,++b,c--,d++,typeof e,delete f);(-1)();(-1)(-2);"
}
2016-08-17 09:43:50 +00:00
new _with _unary _prefix : {
input : {
var bar = ( + new Date ( ) ) . toString ( 32 ) ;
}
expect _exact : 'var bar=(+new Date).toString(32);' ;
}