Small fixes to es7.functionBind and generation tests added.
This commit is contained in:
parent
37f662d790
commit
1a299b2bcc
@ -7,9 +7,6 @@ export var metadata = {
|
||||
stage: 0
|
||||
};
|
||||
|
||||
var CALL = t.identifier("call");
|
||||
var BIND = t.identifier("bind");
|
||||
|
||||
function inferBindContext(bindExpr, scope) {
|
||||
// nothing to infer
|
||||
if (bindExpr.object) return bindExpr.object;
|
||||
@ -27,11 +24,11 @@ export function CallExpression(node, parent, scope, file) {
|
||||
var bindExpr = node.callee;
|
||||
if (!t.isBindExpression(bindExpr)) return;
|
||||
var bindCtx = inferBindContext(bindExpr, scope);
|
||||
node.callee = t.memberExpression(bindExpr.callee, CALL, false);
|
||||
node.callee = t.memberExpression(bindExpr.callee, t.identifier("call"));
|
||||
node.arguments.unshift(bindCtx);
|
||||
}
|
||||
|
||||
export function BindExpression(node, parent, scope, file) {
|
||||
var bindCtx = inferBindContext(node, scope);
|
||||
return t.callExpression(t.memberExpression(node.callee, BIND, false), [bindCtx]);
|
||||
return t.callExpression(t.memberExpression(node.callee, t.identifier("bind")), [bindCtx]);
|
||||
}
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
::foo.bar.foo;
|
||||
::foo.bar["foo"];
|
||||
|
||||
ctx::foo.bar.foo;
|
||||
ctx::foo.bar["foo"];
|
||||
@ -0,0 +1,5 @@
|
||||
::foo.bar.foo;
|
||||
::foo.bar["foo"];
|
||||
|
||||
ctx::foo.bar.foo;
|
||||
ctx::foo.bar["foo"];
|
||||
@ -34,7 +34,8 @@ _.each(helper.get("generation"), function (testSuite) {
|
||||
features: {
|
||||
"es7.comprehensions": true,
|
||||
"es7.asyncFunctions": true,
|
||||
"es7.exportExtensions": true
|
||||
"es7.exportExtensions": true,
|
||||
"es7.functionBind": true
|
||||
}
|
||||
});
|
||||
var actualCode = generate(actualAst, task.options, actual.code).code;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user