lepu-test-platform-web/node_modules/escope/powered-test/es6-rest-args.js

35 lines
6.9 KiB
JavaScript
Raw Normal View History

(function() {
var escope, expect, harmony;
expect = require('chai').expect;
harmony = require('../third_party/esprima');
escope = require('..');
describe('ES6 rest arguments', function() {
return it('materialize rest argument in scope', function() {
var ast, scope, scopeManager;
ast = harmony.parse("function foo(...bar) {\n return bar;\n}");
scopeManager = escope.analyze(ast, {
ecmaVersion: 6
});
expect(scopeManager.scopes).to.have.length(2);
scope = scopeManager.scopes[0];
expect(scope.type).to.be.equal('global');
expect(scope.block.type).to.be.equal('Program');
expect(scope.isStrict).to.be["false"];
expect(scope.variables).to.have.length(1);
scope = scopeManager.scopes[1];
expect(scope.type).to.be.equal('function');
expect(scope.variables).to.have.length(2);
expect(scope.variables[0].name).to.be.equal('arguments');
expect(scope.variables[1].name).to.be.equal('bar');
expect(scope.variables[1].defs[0].name.name).to.be.equal('bar');
return expect(scope.variables[1].defs[0].rest).to.be["true"];
});
});
}).call(this);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImVzNi1yZXN0LWFyZ3MuY29mZmVlIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXVCQTtBQUFBLE1BQUEsdUJBQUE7O0FBQUEsRUFBQSxNQUFBLEdBQVMsT0FBQSxDQUFTLE1BQVQsQ0FBZSxDQUFDLE1BQXpCLENBQUE7O0FBQUEsRUFDQSxPQUFBLEdBQVUsT0FBQSxDQUFTLHdCQUFULENBRFYsQ0FBQTs7QUFBQSxFQUVBLE1BQUEsR0FBUyxPQUFBLENBQVMsSUFBVCxDQUZULENBQUE7O0FBQUEsRUFJQSxRQUFBLENBQVUsb0JBQVYsRUFBK0IsU0FBQSxHQUFBO1dBQzNCLEVBQUEsQ0FBSSxvQ0FBSixFQUF5QyxTQUFBLEdBQUE7QUFDckMsVUFBQSx3QkFBQTtBQUFBLE1BQUEsR0FBQSxHQUFNLE9BQU8sQ0FBQyxLQUF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