mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
refactor: tests for tags
This commit is contained in:
+17
-13
@@ -1,20 +1,24 @@
|
||||
function TokenizationError(message, input, line, stack) {
|
||||
this.name = "TokenizationError";
|
||||
this.message = (message || "");
|
||||
this.input = input;
|
||||
this.line = line;
|
||||
if(stack) this.stack = stack;
|
||||
}
|
||||
TokenizationError.prototype = Error.prototype;
|
||||
const util = require('util');
|
||||
|
||||
function ParseError(message, input, line, stack) {
|
||||
this.name = "ParseError";
|
||||
this.message = (message || "");
|
||||
function TokenizationError(message, input, line) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.name = this.constructor.name;
|
||||
|
||||
this.message = message || "";
|
||||
this.input = input;
|
||||
this.line = line;
|
||||
if(stack) this.stack = stack;
|
||||
}
|
||||
ParseError.prototype = Error.prototype;
|
||||
util.inherits(TokenizationError, Error);
|
||||
|
||||
function ParseError(message, input, line) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.name = "ParseError";
|
||||
|
||||
this.message = message || "";
|
||||
this.input = input;
|
||||
this.line = line;
|
||||
}
|
||||
util.inherits(ParseError, Error);
|
||||
|
||||
module.exports = {
|
||||
TokenizationError, ParseError
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
const lexical = require('./lexical.js');
|
||||
const error = require('./error.js');
|
||||
const ParseError = require('./error.js').ParseError;
|
||||
|
||||
module.exports = function(Tag, Filter) {
|
||||
@@ -60,7 +59,7 @@ module.exports = function(Tag, Filter) {
|
||||
return token;
|
||||
}
|
||||
} catch (e) {
|
||||
throw new ParseError(e.message, token.input, token.line, e.stack);
|
||||
throw new ParseError(e.message, token.input, token.line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user