michael@0: // vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: michael@0: function testUKeyUObject(a, key1, key2, key3) { michael@0: a.a = function () { return this.d; } michael@0: a.b = function () { return this.e; } michael@0: a.c = function() { return this.f; } michael@0: a.d = 20; michael@0: a.e = "hi"; michael@0: a.f = 500; michael@0: assertEq(a[key1](), 20); michael@0: assertEq(a[key2](), "hi"); michael@0: assertEq(a[key3](), 500); michael@0: } michael@0: michael@0: function testVKeyUObject(a, key1, key2, key3) { michael@0: a.a = function () { return this.d; } michael@0: a.b = function () { return this.e; } michael@0: a.c = function() { return this.f; } michael@0: a.d = 20; michael@0: a.e = "hi"; michael@0: a.f = 500; michael@0: assertEq(a["" + key1](), 20); michael@0: assertEq(a["" + key2](), "hi"); michael@0: assertEq(a["" + key3](), 500); michael@0: } michael@0: michael@0: function testKKeyUObject(a) { michael@0: a.a = function () { return this.d; } michael@0: a.b = function () { return this.e; } michael@0: a.c = function() { return this.f; } michael@0: a.d = 20; michael@0: a.e = "hi"; michael@0: a.f = 500; michael@0: var key1 = "a"; michael@0: var key2 = "b"; michael@0: var key3 = "c"; michael@0: assertEq(a[key1](), 20); michael@0: assertEq(a[key2](), "hi"); michael@0: assertEq(a[key3](), 500); michael@0: } michael@0: michael@0: function testUKeyVObject(key1, key2, key3) { michael@0: a = { a: function () { return this.d; }, michael@0: b: function () { return this.e; }, michael@0: c: function () { return this.f; }, michael@0: d: 20, michael@0: e: "hi", michael@0: f: 500 michael@0: }; michael@0: assertEq(a[key1](), 20); michael@0: assertEq(a[key2](), "hi"); michael@0: assertEq(a[key3](), 500); michael@0: } michael@0: michael@0: function testVKeyVObject(key1, key2, key3) { michael@0: a = { a: function () { return this.d; }, michael@0: b: function () { return this.e; }, michael@0: c: function () { return this.f; }, michael@0: d: 20, michael@0: e: "hi", michael@0: f: 500 michael@0: }; michael@0: assertEq(a["" + key1](), 20); michael@0: assertEq(a["" + key2](), "hi"); michael@0: assertEq(a["" + key3](), 500); michael@0: } michael@0: michael@0: function testKKeyVObject(a) { michael@0: a = { a: function () { return this.d; }, michael@0: b: function () { return this.e; }, michael@0: c: function () { return this.f; }, michael@0: d: 20, michael@0: e: "hi", michael@0: f: 500 michael@0: }; michael@0: var key1 = "a"; michael@0: var key2 = "b"; michael@0: var key3 = "c"; michael@0: assertEq(a[key1](), 20); michael@0: assertEq(a[key2](), "hi"); michael@0: assertEq(a[key3](), 500); michael@0: } michael@0: michael@0: for (var i = 0; i < 5; i++) { michael@0: testUKeyUObject({}, "a", "b", "c"); michael@0: testVKeyUObject({}, "a", "b", "c"); michael@0: testKKeyUObject({}); michael@0: testUKeyVObject("a", "b", "c"); michael@0: testVKeyVObject("a", "b", "c"); michael@0: testKKeyVObject(); michael@0: } michael@0: michael@0: