Browse Source

EAGLESIX-2691 First stab at the templates VariadicExpressionT class. It depends upon other classes that are not yet converted so it is not working.

Tony Ennis 11 years ago
parent
commit
b29947ce0d

+ 19 - 0
lib/pipeline/expressions/VariadicExpressionT.js

@@ -0,0 +1,19 @@
+"use strict";
+
+/**
+ * A factory and base class for all expressions that are variadic (AKA they accept any number of arguments)
+ * @class VariadicExpressionT
+ * @namespace mungedb-aggregate.pipeline.expressions
+ * @module mungedb-aggregate
+ * @constructor
+ **/
+
+var VariadicExpressionT = module.exports = function VariadicExpressionT(SubClass) {
+
+	var VariadicExpression = function VariadicExpression() {
+		base.call(this);
+	}, klass = VariadicExpression, base = require("./NaryExpressionT")(SubClass), proto = klass.prototype = Object.create(base.prototype, {constructor: {value: klass}});
+
+	return VariadicExpression;
+};
+

+ 29 - 0
test/lib/pipeline/expressions/VariadicExpressionT_test.js

@@ -0,0 +1,29 @@
+"use strict";
+
+var assert = require("assert"),
+	VariadicExpressionT = require("../../../../lib/pipeline/expressions/VariadicExpressionT"),
+	NaryExpressionT = require("../../../../lib/pipeline/expressions/NaryExpressionT");
+
+
+//TODO: refactor these test cases using Expression.parseOperand() or something because these could be a whole lot cleaner...
+module.exports = {
+
+	"VariaticExpression": {
+
+		"constructor()": {
+
+			"should not throw Error when constructing without args": function testConstructor() {
+				assert.doesNotThrow(function () {
+					new VariadicExpressionT({});
+				});
+			},
+
+			"should be an instance of NaryExpression": function () {
+				assert(new VariadicExpressionT() instanceof NaryExpression);
+			}
+		}
+	}
+};
+
+
+if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);