lepu-test-platform-web/node_modules/escope/powered-test/es6-template-literal.js

45 lines
10 KiB
JavaScript
Raw Normal View History

(function() {
var escope, expect, harmony;
expect = require('chai').expect;
harmony = require('../third_party/esprima');
escope = require('..');
describe('ES6 template literal', function() {
return it('refer variables', function() {
var ast, scope, scopeManager;
ast = harmony.parse("(function () {\n let i, j, k;\n function testing() { }\n let template = testing`testing ${i} and ${j}`\n return template;\n}());");
scopeManager = escope.analyze(ast, {
ecmaVersion: 6
});
expect(scopeManager.scopes).to.have.length(3);
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(0);
scope = scopeManager.scopes[1];
expect(scope.type).to.be.equal('function');
expect(scope.block.type).to.be.equal('FunctionExpression');
expect(scope.isStrict).to.be["false"];
expect(scope.variables).to.have.length(6);
expect(scope.variables[0].name).to.be.equal('arguments');
expect(scope.variables[1].name).to.be.equal('i');
expect(scope.variables[2].name).to.be.equal('j');
expect(scope.variables[3].name).to.be.equal('k');
expect(scope.variables[4].name).to.be.equal('testing');
expect(scope.variables[5].name).to.be.equal('template');
expect(scope.references).to.have.length(5);
expect(scope.references[0].identifier.name).to.be.equal('template');
expect(scope.references[1].identifier.name).to.be.equal('testing');
expect(scope.references[2].identifier.name).to.be.equal('i');
expect(scope.references[3].identifier.name).to.be.equal('j');
return expect(scope.references[4].identifier.name).to.be.equal('template');
});
});
}).call(this);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImVzNi10ZW1wbGF0ZS1saXRlcmFsLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF1QkE7QUFBQSxNQUFBLHVCQUFBOztBQUFBLEVBQUEsTUFBQSxHQUFTLE9BQUEsQ0FBUyxNQUFULENBQWUsQ0FBQyxNQUF6QixDQUFBOztBQUFBLEVBQ0EsT0FBQSxHQUFVLE9BQUEsQ0F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