aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-util.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-util.js')
-rw-r--r--tests/test-util.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test-util.js b/tests/test-util.js
index 552868f..2104a2e 100644
--- a/tests/test-util.js
+++ b/tests/test-util.js
@@ -48,6 +48,52 @@ var areArraysEqual = function areArraysEqual(array1, array2) {
return true;
};
+// testing util.heir
+exports.ensureHeir = function (test) {
+ var fedlimid = {}, naoise = {};
+
+ function Father(x) {
+ this.family = x;
+ }
+
+ Father.prototype.getFamily = function getFamily() {
+ return this.family;
+ };
+
+ function Son(x, w) {
+ Father.call(this, x);
+ this.wife = w;
+ }
+
+ Son.prototype = util.heir(Father);
+ Son.prototype.constructor = Son;
+
+ Son.prototype.getWife = function getWife() {
+ return this.wife;
+ };
+
+ Son.prototype.getFamily = function getFamily() {
+ var upFamily =
+ Father.prototype.getFamily.call(this);
+ return upFamily + ", " + this.wife;
+ };
+
+ // for curious and non-Celtic
+ // http://en.wikipedia.org/wiki/Deirdre :)
+ fedlimid = new Father("mac Daill");
+ naoise = new Son("Usnech", "Deirdre");
+
+ test.assertEqual(fedlimid.getFamily(), "mac Daill",
+ "checking creation of new simple object");
+
+ test.assertEqual(naoise.getWife(), "Deirdre",
+ "checking creation of new daughter object");
+
+ test.assertEqual(naoise.getFamily(), "Usnech, Deirdre",
+ "checking creation of new overloaded method");
+};
+
+
// testing util.isInList
exports.ensureIsInListTrue = function (test) {
test.assert(util.isInList("a", ["a"]),