Browse Source

EAGLESIX-2695 Added the check for the number of arguments. Added rudimentary tests.

Tony Ennis 11 years ago
parent
commit
c99711f03a

+ 1 - 1
lib/pipeline/expressions/LetExpression.js

@@ -1,7 +1,7 @@
 "use strict";
 "use strict";
 
 
 var LetExpression = module.exports = function LetExpression(vars, subExpression){
 var LetExpression = module.exports = function LetExpression(vars, subExpression){
-	//if (arguments.length !== 2) throw new Error("Two args expected");
+	if (arguments.length !== 2) throw new Error("Two args expected");
 	this._variables = vars;
 	this._variables = vars;
 	this._subExpression = subExpression;
 	this._subExpression = subExpression;
 }, klass = LetExpression, Expression = require("./Expression"), base = Expression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 }, klass = LetExpression, Expression = require("./Expression"), base = Expression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});

+ 32 - 3
test/lib/pipeline/expressions/LetExpression_test.js

@@ -1,3 +1,32 @@
-/**
- * Created by tennis on 10/31/14.
- */
+"use strict";
+var assert = require("assert"),
+	LetExpression = require("../../../../lib/pipeline/expressions/LetExpression"),
+	Expression = require("../../../../lib/pipeline/expressions/Expression");
+
+
+module.exports = {
+
+	"LetExpression": {
+
+		"constructor()": {
+
+			"should throw an Error when constructing without args": function () {
+				assert.throws(function () {
+					new LetExpression();
+				});
+			},
+			"should throw Error when constructing with one arg": function () {
+				assert.throws(function () {
+					new LetExpression(1);
+				});
+			},
+			"should not throw when constructing with two args": function () {
+				assert.doesNotThrow(function () {
+					new LetExpression(1, 2);
+				});
+			}
+		}
+	}
+};
+
+if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);