add playground
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Test {
|
||||
constructor() {
|
||||
arr.map(x => x * x);
|
||||
arr.map(x => x * x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var _ref;
|
||||
var _temp, _ref;
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
var _temp;
|
||||
console.log((_temp = [123], _ref = _toArray(_temp), x = _ref[0], _temp));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
test["catch"];
|
||||
test["catch"]["foo"];
|
||||
test["catch"].foo;
|
||||
test["catch"];
|
||||
test["catch"]["foo"];
|
||||
test["catch"].foo;
|
||||
|
||||
1
test/fixtures/transformation/misc/_member-expression-literals/actual.js
vendored
Normal file
1
test/fixtures/transformation/misc/_member-expression-literals/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
obj["x"] = 2;
|
||||
3
test/fixtures/transformation/misc/_member-expression-literals/expected.js
vendored
Normal file
3
test/fixtures/transformation/misc/_member-expression-literals/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
obj.x = 2;
|
||||
13
test/fixtures/transformation/playground/memoization-assignment-operator/actual.js
vendored
Normal file
13
test/fixtures/transformation/playground/memoization-assignment-operator/actual.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var obj = {};
|
||||
|
||||
obj.x ?= 2;
|
||||
|
||||
console.log(obj.x ?= 2);
|
||||
|
||||
obj[x()] ?= 2;
|
||||
|
||||
console.log(obj[x()] ?= 2);
|
||||
|
||||
obj[y()][x()] ?= 2;
|
||||
|
||||
console.log(obj[y()][x()] ?= 2);
|
||||
20
test/fixtures/transformation/playground/memoization-assignment-operator/exec.js
vendored
Normal file
20
test/fixtures/transformation/playground/memoization-assignment-operator/exec.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
var obj = {};
|
||||
obj.x ?= 2;
|
||||
assert.equal(obj.x, 2);
|
||||
|
||||
obj = {};
|
||||
assert.equal(obj.x ?= 2, 2);
|
||||
|
||||
obj = { x: 1 };
|
||||
obj.x ?= 2;
|
||||
assert.equal(obj.x, 1);
|
||||
|
||||
obj = { x: 1 };
|
||||
assert.equal(obj.x ?= 2, 1);
|
||||
|
||||
obj = { x: undefined }
|
||||
obj.x ?= 2;
|
||||
assert.equal(obj.x, undefined);
|
||||
|
||||
obj = { x: undefined }
|
||||
assert.equal(obj.x ?= 2, undefined);
|
||||
25
test/fixtures/transformation/playground/memoization-assignment-operator/expected.js
vendored
Normal file
25
test/fixtures/transformation/playground/memoization-assignment-operator/expected.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
var _propKey2, _obj2, _propKey4;
|
||||
var _hasOwn = Object.prototype.hasOwnProperty;
|
||||
var obj = {};
|
||||
|
||||
if (!_hasOwn.call(obj, "x")) obj.x = 2;
|
||||
|
||||
|
||||
console.log((!_hasOwn.call(obj, "x") && (obj.x = 2), obj.x));
|
||||
|
||||
var _propKey = x();
|
||||
|
||||
if (!_hasOwn.call(obj, _propKey)) obj[_propKey] = 2;
|
||||
|
||||
|
||||
console.log((_propKey2 = x(), !_hasOwn.call(obj, _propKey2) && (obj[_propKey2] = 2), obj[_propKey2]));
|
||||
|
||||
var _obj = obj[y()];
|
||||
var _propKey3 = x();
|
||||
|
||||
if (!_hasOwn.call(_obj, _propKey3)) _obj[_propKey3] = 2;
|
||||
|
||||
|
||||
console.log((_obj2 = obj[y()], _propKey4 = x(), !_hasOwn.call(_obj2, _propKey4) && (_obj2[_propKey4] = 2), _obj2[_propKey4]));
|
||||
5
test/fixtures/transformation/playground/method-binding/actual.js
vendored
Normal file
5
test/fixtures/transformation/playground/method-binding/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var fn = obj:method;
|
||||
var fn = obj:method("foob");
|
||||
var fn = obj[foo]:method;
|
||||
var fn = obj.foo:method;
|
||||
var fn = obj[foo()]:method;
|
||||
22
test/fixtures/transformation/playground/method-binding/exec.js
vendored
Normal file
22
test/fixtures/transformation/playground/method-binding/exec.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var obj = {
|
||||
foo: "foo",
|
||||
bar: "bar",
|
||||
getFoo: function () {
|
||||
return this.foo;
|
||||
},
|
||||
getBar: function (arg) {
|
||||
return arg + " " + this.bar;
|
||||
},
|
||||
getZoo: function (a, b) {
|
||||
return this.foo + " " + this.bar + " " + a + " " + b;
|
||||
}
|
||||
};
|
||||
|
||||
var foo = obj:getFoo;
|
||||
assert.equal(foo(), "foo");
|
||||
|
||||
var bar = obj:getBar("foo");
|
||||
assert.equal(bar(), "foo bar");
|
||||
|
||||
var zoo = obj:getZoo("foo");
|
||||
assert.equal(zoo("bar"), "foo bar foo bar");
|
||||
8
test/fixtures/transformation/playground/method-binding/expected.js
vendored
Normal file
8
test/fixtures/transformation/playground/method-binding/expected.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var _temp;
|
||||
var fn = obj.method.bind(obj);
|
||||
var fn = obj.method.bind(obj, "foob");
|
||||
var fn = obj[foo].method.bind(obj[foo]);
|
||||
var fn = obj.foo.method.bind(obj.foo);
|
||||
var fn = (_temp = obj[foo()], _temp.method.bind(_temp));
|
||||
3
test/fixtures/transformation/playground/options.json
vendored
Normal file
3
test/fixtures/transformation/playground/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"playground": true
|
||||
}
|
||||
@@ -37,10 +37,11 @@ var run = function (task, done) {
|
||||
err.message += util.codeFrame(execCode);
|
||||
throw err;
|
||||
}
|
||||
} else {
|
||||
var actualCode = actual.code;
|
||||
var expectCode = expect.code;
|
||||
}
|
||||
|
||||
var actualCode = actual.code;
|
||||
var expectCode = expect.code;
|
||||
if (!execCode || actualCode) {
|
||||
result = transform(actualCode, getOpts(actual));
|
||||
actualCode = result.code;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user