lepu-test-platform-web/node_modules/escope/powered-test/function-expression-name.js

42 lines
8.7 KiB
JavaScript
Raw Normal View History

(function() {
var escope, esprima, expect, harmony;
expect = require('chai').expect;
esprima = require('esprima');
harmony = require('../third_party/esprima');
escope = require('..');
describe('function name', function() {
return it('should create its special scope', function() {
var ast, globalScope, scope, scopeManager;
ast = esprima.parse("(function name() {\n}());");
scopeManager = escope.analyze(ast);
expect(scopeManager.scopes).to.have.length(3);
globalScope = scopeManager.scopes[0];
expect(globalScope.type).to.be.equal('global');
expect(globalScope.variables).to.have.length(0);
expect(globalScope.references).to.have.length(0);
expect(globalScope.isArgumentsMaterialized()).to.be["true"];
scope = scopeManager.scopes[1];
expect(scope.type).to.be.equal('function-expression-name');
expect(scope.variables).to.have.length(1);
expect(scope.variables[0].name).to.be.equal('name');
expect(scope.isArgumentsMaterialized()).to.be["true"];
expect(scope.references).to.have.length(0);
expect(scope.upper === globalScope).to.be["true"];
scope = scopeManager.scopes[2];
expect(scope.type).to.be.equal('function');
expect(scope.variables).to.have.length(1);
expect(scope.variables[0].name).to.be.equal('arguments');
expect(scope.isArgumentsMaterialized()).to.be["false"];
expect(scope.references).to.have.length(0);
return expect(scope.upper === scopeManager.scopes[1]).to.be["true"];
});
});
}).call(this);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZ1bmN0aW9uLWV4cHJlc3Npb24tbmFtZS5jb2ZmZWUiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBdUJBO0FBQUEsTUFBQSxnQ0FBQTs7QUFBQSxFQUFBLE1BQUEsR0FBUyxPQUFBLENBQVMsTUFBVCxDQUFlLENBQUMsTUFBekIsQ0FBQTs7QUFBQSxFQUNBLE9BQUEsR0FBVSxPQUFBLENBQVMsU0FBVCxDQURWLENBQUE7O0FBQUEsRUFFQSxPQUFBLEdBQVUsT0FBQSxDQUFTLHdCQUFULENBRlYsQ0FBQTs7QUFBQSxFQUdBLE1BQUEsR0F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