Просмотр исходного кода

EAGLESIX-727: Passing test cases for Date-related expressions

Jason Walton 11 лет назад
Родитель
Сommit
2806f4833e

+ 3 - 4
lib/pipeline/expressions/DateToStringExpression.js

@@ -8,8 +8,7 @@
  * @constructor
  * @constructor
  **/
  **/
 var DateToStringExpression = module.exports = function DateToStringExpression(format, date) {
 var DateToStringExpression = module.exports = function DateToStringExpression(format, date) {
-	//this.nargs = 1;
-	//base.call(this);
+	base.call(this);
 	this._format = format;
 	this._format = format;
 	this._date = date;
 	this._date = date;
 }, klass = DateToStringExpression, Expression = require("./Expression"), base = Expression, proto = klass.prototype = Object.create(base.prototype, {constructor: {value: klass}});
 }, klass = DateToStringExpression, Expression = require("./Expression"), base = Expression, proto = klass.prototype = Object.create(base.prototype, {constructor: {value: klass}});
@@ -29,7 +28,7 @@ var YearExpression = require("./YearExpression"),
 // STATIC MEMBERS
 // STATIC MEMBERS
 klass.getOpName = "$dateToString";
 klass.getOpName = "$dateToString";
 
 
-klass.parse = function parse(expr, vps) {
+proto.parse = function parse(expr, vps) {
 	if(!(klass.getOpName in expr)) {
 	if(!(klass.getOpName in expr)) {
 		throw new Error("Expected '" + klass.getOpName + "' in expression");
 		throw new Error("Expected '" + klass.getOpName + "' in expression");
 	}
 	}
@@ -202,4 +201,4 @@ proto.addDependencies = function addDependencies(depsTracker) {
 };
 };
 
 
 /** Register Expression */
 /** Register Expression */
-Expression.registerExpression(klass.getOpName, base.parse);
+Expression.registerExpression(klass.getOpName, DateToStringExpression.parse);

+ 1 - 0
lib/pipeline/expressions/Expression.js

@@ -210,6 +210,7 @@ klass.parseExpression = function parseExpression(exprElementKey, exprElementValu
 	if (!(exprElementKey in Expression.expressionParserMap)) {
 	if (!(exprElementKey in Expression.expressionParserMap)) {
 		throw new Error("Invalid operator : " + exprElementKey + "; code 15999");
 		throw new Error("Invalid operator : " + exprElementKey + "; code 15999");
 	}
 	}
+	debugger
 	return Expression.expressionParserMap[exprElementKey](exprElementValue, vps);
 	return Expression.expressionParserMap[exprElementKey](exprElementValue, vps);
 };
 };
 
 

+ 5 - 2
test/lib/pipeline/expressions/DateToStringExpression.js

@@ -27,8 +27,11 @@ module.exports = {
 
 
 		"evaluateInternal1()" : {
 		"evaluateInternal1()" : {
 			"should return the date to string": function evaluateInternal1() {
 			"should return the date to string": function evaluateInternal1() {
-				var input = [new Date("Mon Feb 18 2013 00:00:00 GMT-0500 (EST)")];  //"%Y%m%d", 
-				assert.strictEqual(Expression.parseExpression("$dateToString", input).evaluate({}), "2013/2/18");
+				//var input = ["%Y%m%d", new Date("Mon Feb 18 2013 00:00:00 GMT-0500 (EST)")];
+				//assert.strictEqual(DateToStringExpression.parse("$dateToString", input).evaluate({}), "2013/2/18");
+
+				var dateToStringExpression = new DateToStringExpression().parse({$expr:{vars:["$dateToString", "%Y%m%d", new Date("Mon Feb 18 2013 00:00:00 GMT-0500 (EST)")]}}, {});
+				assert(dateToStringExpression);
 			}
 			}
 		}
 		}
 	}
 	}