refactor: tests for tags

This commit is contained in:
harttle
2016-09-26 21:52:06 +08:00
parent afca74b238
commit ddc17a6b93
27 changed files with 724 additions and 408 deletions
+2 -3
View File
@@ -1,6 +1,5 @@
const _ = require('lodash');
const lexical = require('./lexical.js');
const error = require('./error.js');
var scope = {
get: function(str) {
@@ -21,7 +20,7 @@ var scope = {
return this;
},
push: function(ctx) {
if (!ctx) error(`trying to push ${ctx} into scopes`);
if (!ctx) throw new Error(`trying to push ${ctx} into scopes`);
return this.scopes.push(ctx);
},
pop: function() {
@@ -31,6 +30,6 @@ var scope = {
exports.factory = function(_ctx) {
var ctx = Object.create(scope);
ctx.scopes = _ctx ? [_ctx] : [];
ctx.scopes = [_ctx || {}];
return ctx;
};