diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-06-03 16:08:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-03 16:08:10 +0800 |
commit | 84634da4b5e581c36686082b1071fdf646775f49 (patch) | |
tree | b3446b31bd8abdb2ced837e4f601fad21a954503 /test/compress/properties.js | |
parent | 17436218891781a5dc4fad8a9c23080c254aa695 (diff) | |
download | tracifyjs-84634da4b5e581c36686082b1071fdf646775f49.tar.gz tracifyjs-84634da4b5e581c36686082b1071fdf646775f49.zip |
add tests for `AST_SymbolAccessor` (#2049)
Diffstat (limited to 'test/compress/properties.js')
-rw-r--r-- | test/compress/properties.js | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/test/compress/properties.js b/test/compress/properties.js index d49b9ea4..a83acc10 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -556,7 +556,75 @@ native_prototype: { } } -issue_2040: { +accessor_boolean: { + input: { + var a = 1; + var b = { + get true() { + return a; + }, + set false(c) { + a = c; + } + }; + console.log(b.true, b.false = 2, b.true); + } + expect_exact: 'var a=1;var b={get true(){return a},set false(c){a=c}};console.log(b.true,b.false=2,b.true);' + expect_stdout: "1 2 2" +} + +accessor_get_set: { + input: { + var a = 1; + var b = { + get set() { + return a; + }, + set get(c) { + a = c; + } + }; + console.log(b.set, b.get = 2, b.set); + } + expect_exact: 'var a=1;var b={get set(){return a},set get(c){a=c}};console.log(b.set,b.get=2,b.set);' + expect_stdout: "1 2 2" +} + +accessor_null_undefined: { + input: { + var a = 1; + var b = { + get null() { + return a; + }, + set undefined(c) { + a = c; + } + }; + console.log(b.null, b.undefined = 2, b.null); + } + expect_exact: 'var a=1;var b={get null(){return a},set undefined(c){a=c}};console.log(b.null,b.undefined=2,b.null);' + expect_stdout: "1 2 2" +} + +accessor_number: { + input: { + var a = 1; + var b = { + get 42() { + return a; + }, + set 42(c) { + a = c; + } + }; + console.log(b[42], b[42] = 2, b[42]); + } + expect_exact: 'var a=1;var b={get 42(){return a},set 42(c){a=c}};console.log(b[42],b[42]=2,b[42]);' + expect_stdout: "1 2 2" +} + +accessor_string: { input: { var a = 1; var b = { @@ -572,3 +640,20 @@ issue_2040: { expect_exact: 'var a=1;var b={get"a-b"(){return a},set"a-b"(c){a=c}};console.log(b["a-b"],b["a-b"]=2,b["a-b"]);' expect_stdout: "1 2 2" } + +accessor_this: { + input: { + var a = 1; + var b = { + get this() { + return a; + }, + set this(c) { + a = c; + } + }; + console.log(b.this, b.this = 2, b.this); + } + expect_exact: 'var a=1;var b={get this(){return a},set this(c){a=c}};console.log(b.this,b.this=2,b.this);' + expect_stdout: "1 2 2" +} |