2015-01-11 20:07:19 +00:00
arrow _function _parens : {
input : {
something && ( ( ) => { } ) ;
}
expect _exact : "something&&(()=>{});"
}
arrow _function _parens _2 : {
input : {
( ( ) => null ) ( ) ;
}
expect _exact : "(()=>null)();"
}
2015-08-14 21:05:42 +00:00
typeof _arrow _functions : {
options = {
evaluate : true
}
input : {
2016-06-20 11:59:26 +00:00
var foo = typeof ( x ) => null ;
2015-08-14 21:05:42 +00:00
}
2016-06-20 11:59:26 +00:00
expect _exact : "var foo=\"function\";"
2015-08-14 21:05:42 +00:00
}
2015-10-27 00:40:46 +00:00
classes : {
input : {
class SomeClass {
constructor ( ) {
} ;
foo ( ) { } ;
} ;
class NoSemi {
constructor ( ... args ) {
}
foo ( ) { }
} ;
class ChildClass extends SomeClass { } ;
var asExpression = class AsExpression { } ;
var nameless = class { } ;
}
expect _exact : "class SomeClass{constructor(){}foo(){}}class NoSemi{constructor(...args){}foo(){}}class ChildClass extends SomeClass{}var asExpression=class AsExpression{};var nameless=class{};"
}
2015-10-27 00:51:47 +00:00
class _statics : {
input : {
x = class {
static staticMethod ( ) { }
static get foo ( ) { }
static set bar ( ) { }
static ( ) { /* "static" can be a method name! */ }
get ( ) { /* "get" can be a method name! */ }
set ( ) { /* "set" can be a method name! */ }
}
}
expect _exact : "x=class{static staticMethod(){}static get foo(){}static set bar(){}static(){}get(){}set(){}};"
}
2015-11-21 12:20:20 +00:00
class _name _can _be _mangled : {
mangle = { } ;
input : {
function x ( ) {
class Foo {
}
var class1 = Foo
var class2 = class Bar { }
}
}
expect : {
function x ( ) {
class a { }
2016-04-18 13:51:32 +00:00
var n = a
var r = class a { }
2015-11-21 12:20:20 +00:00
}
}
}
2015-11-21 13:59:18 +00:00
class _name _can _be _preserved : {
mangle = {
keep _classnames : true
}
input : {
function x ( ) {
( class Baz { } ) ;
class Foo { } ;
}
}
expect : {
function x ( ) {
( class Baz { } ) ;
class Foo { } ;
}
}
}
2016-05-26 15:00:37 +00:00
classes _can _have _generators : {
input : {
class Foo {
* bar ( ) { }
static * baz ( ) { }
}
}
expect : {
class Foo {
* bar ( ) { }
static * baz ( ) { }
}
}
}
2016-07-05 22:40:28 +00:00
classes _can _have _computed _generators : {
input : {
class C4 {
* [ 'constructor' ] ( ) { }
}
}
expect : {
class C4 {
* [ 'constructor' ] ( ) { }
}
}
}
classes _can _have _computed _static : {
input : {
class C4 {
static [ 'constructor' ] ( ) { }
}
}
expect : {
class C4 {
static [ 'constructor' ] ( ) { }
}
}
}
2016-07-29 01:18:21 +00:00
class _methods _and _getters _with _keep _quoted _props _enabled : {
beautify = {
quote _style : 3 ,
keep _quoted _props : true ,
}
input : {
class clss {
a ( ) { }
"b" ( ) { }
get c ( ) { return "c" }
get "d" ( ) { return "d" }
set e ( a ) { doSomething ( a ) ; }
set 'f' ( a ) { doSomething ( b ) ; }
static g ( ) { }
static "h" ( ) { }
}
}
expect _exact : 'class clss{a(){}"b"(){}get c(){return"c"}get"d"(){return"d"}set e(a){doSomething(a)}set\'f\'(a){doSomething(b)}static g(){}static"h"(){}}'
}
2015-11-21 14:48:23 +00:00
new _target : {
input : {
new . target ;
new . target . name ;
}
expect _exact : "new.target;new.target.name;"
}
2015-08-17 15:23:43 +00:00
number _literals : {
2015-08-17 10:50:56 +00:00
input : {
0b1001 ;
0B1001 ;
0o11 ;
0O11 ;
}
expect : {
9 ;
9 ;
9 ;
9 ;
}
}
2015-09-05 22:01:25 +00:00
2016-01-29 20:47:49 +00:00
import _statement : {
input : {
import "mod-name" ;
2016-02-21 17:06:09 +00:00
import Foo from "bar" ;
2016-02-26 21:12:19 +00:00
import { Bar , Baz } from 'lel' ;
import Bar , { Foo } from 'lel' ;
import { Bar as kex , Baz as food } from 'lel' ;
2016-02-21 17:06:09 +00:00
}
2016-02-26 21:12:19 +00:00
expect _exact : "import\"mod-name\";import Foo from\"bar\";import{Bar,Baz}from\"lel\";import Bar,{Foo}from\"lel\";import{Bar as kex,Baz as food}from\"lel\";"
2016-02-21 17:06:09 +00:00
}
2016-02-27 12:24:18 +00:00
export _statement : {
input : {
export default 1 ;
export var foo = 4 ;
export let foo = 6 ;
export const foo = 6 ;
export function foo ( ) { } ;
export class foo { } ;
}
expect _exact : "export default 1;export var foo=4;export let foo=6;export const foo=6;export function foo(){};export class foo{};"
}
2016-02-21 17:06:09 +00:00
import _statement _mangling : {
mangle = { } ;
input : {
import Foo from "foo" ;
2016-02-27 12:01:16 +00:00
import Bar , { Food } from "lel" ;
import { What as Whatever } from "lel" ;
2016-02-21 17:06:09 +00:00
Foo ( ) ;
2016-02-27 12:01:16 +00:00
Bar ( ) ;
Food ( ) ;
Whatever ( ) ;
2016-02-21 17:06:09 +00:00
}
expect : {
2016-04-18 13:51:32 +00:00
import l from "foo" ;
import e , { Food as o } from "lel" ;
import { What as f } from "lel" ;
l ( ) ;
e ( ) ;
o ( ) ;
f ( ) ;
2016-01-29 20:47:49 +00:00
}
}
2016-02-27 12:40:57 +00:00
export _statement _mangling : {
mangle = { } ;
input : {
export var foo = 6 ;
export function bar ( ) { }
export class Baz { }
bar ( foo , Baz )
}
expect : {
export var foo = 6 ;
export function bar ( ) { }
export class Baz { }
bar ( foo , Baz )
}
}
2016-03-27 11:21:39 +00:00
// https://github.com/mishoo/UglifyJS2/issues/1021
regression _for _of _const : {
input : {
for ( const x of y ) { }
for ( const x in y ) { }
}
expect : {
for ( const x of y ) ; for ( const x in y ) ;
}
}
2015-09-05 22:01:25 +00:00
// Fabio: My patches accidentally caused a crash whenever
// there's an extraneous set of parens around an object.
regression _cannot _destructure : {
input : {
var x = ( { x : 3 } ) ;
x ( ( { x : 3 } ) ) ;
}
expect _exact : "var x={x:3};x({x:3});" ;
}
2015-10-26 20:56:59 +00:00
regression _cannot _use _of : {
input : {
function of ( ) {
}
var of = "is a valid variable name" ;
of = { of : "is ok" } ;
x . of ;
of : foo ( )
}
expect : {
function of ( ) { }
var of = "is a valid variable name" ;
of = { of : "is ok" } ;
x . of ;
foo ( ) ; /* Label statement missing? No prob. */
}
2016-09-01 07:35:31 +00:00
}
fat _arrow _as _param : {
input : {
foo ( x => x ) ;
foo ( x => x , y => y ) ;
foo ( x => ( x , x ) ) ;
foo ( x => ( x , x ) , y => ( y , y ) ) ;
}
expect _exact : "foo(x=>x);foo(x=>x,y=>y);foo(x=>(x,x));foo(x=>(x,x),y=>(y,y));"
}