feature: strict_variables, working on #9

This commit is contained in:
harttle
2016-09-26 22:49:09 +08:00
parent 38916ae864
commit be6c67a1ba
7 changed files with 110 additions and 41 deletions
+18
View File
@@ -18,6 +18,24 @@ describe('scope', function() {
scope.get('foo').should.equal('bar');
});
it('should get undefined property', function() {
function fn(){
scope.get('notdefined');
}
expect(fn).to.not.throw();
expect(scope.get('notdefined')).to.equal(undefined);
});
it('should throw undefined in strict mode', function() {
scope = Scope.factory(ctx, {
strict: true
});
function fn(){
scope.get('notdefined');
}
expect(fn).to.throw(/undefined variable: notdefined/);
});
it('should get all property', function() {
scope.get().should.deep.equal(ctx);
expect(scope.get('')).to.equal(undefined);