add playground

This commit is contained in:
Sebastian McKenzie
2014-11-25 23:50:50 +11:00
parent e12cca974a
commit d184bc93b9
38 changed files with 444 additions and 73 deletions

View File

@@ -1,5 +1,5 @@
class Test {
constructor() {
arr.map(x => x * x);
arr.map(x => x * x);
}
}

View File

@@ -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));

View File

@@ -1,6 +1,6 @@
"use strict";
test["catch"];
test["catch"]["foo"];
test["catch"].foo;
test["catch"];
test["catch"]["foo"];
test["catch"].foo;

View File

@@ -0,0 +1 @@
obj["x"] = 2;

View File

@@ -0,0 +1,3 @@
"use strict";
obj.x = 2;

View 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);

View 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);

View 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]));

View 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;

View 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");

View 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));

View File

@@ -0,0 +1,3 @@
{
"playground": true
}

View File

@@ -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;