diff options
Diffstat (limited to 'V8Binding/v8/test/mjsunit/simple-constructor.js')
-rwxr-xr-x | V8Binding/v8/test/mjsunit/simple-constructor.js | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/V8Binding/v8/test/mjsunit/simple-constructor.js b/V8Binding/v8/test/mjsunit/simple-constructor.js index b26d651..e9ae921 100755 --- a/V8Binding/v8/test/mjsunit/simple-constructor.js +++ b/V8Binding/v8/test/mjsunit/simple-constructor.js @@ -53,9 +53,11 @@ function f4(x) { } o1_1 = new f1(); +assertEquals(1, o1_1.x, "1"); o1_2 = new f1(); -assertArrayEquals(["x"], props(o1_1)); -assertArrayEquals(["x"], props(o1_2)); +assertEquals(1, o1_1.x, "2"); +assertArrayEquals(["x"], props(o1_1), "3"); +assertArrayEquals(["x"], props(o1_2), "4"); o2_1 = new f2(0); o2_2 = new f2(0); @@ -76,3 +78,63 @@ o4_1_1 = new f4(1); o4_1_2 = new f4(1); assertArrayEquals(["x", "y"], props(o4_1_1)); assertArrayEquals(["x", "y"], props(o4_1_2)); + +function f5(x, y) { + this.x = x; + this.y = y; +} + +function f6(x, y) { + this.y = y; + this.x = x; +} + +function f7(x, y, z) { + this.x = x; + this.y = y; +} + +function testArgs(fun) { + obj = new fun(); + assertArrayEquals(["x", "y"], props(obj)); + assertEquals(void 0, obj.x); + assertEquals(void 0, obj.y); + + obj = new fun("x"); + assertArrayEquals(["x", "y"], props(obj)); + assertEquals("x", obj.x); + assertEquals(void 0, obj.y); + + obj = new fun("x", "y"); + assertArrayEquals(["x", "y"], props(obj)); + assertEquals("x", obj.x); + assertEquals("y", obj.y); + + obj = new fun("x", "y", "z"); + assertArrayEquals(["x", "y"], props(obj)); + assertEquals("x", obj.x); + assertEquals("y", obj.y); +} + +for (var i = 0; i < 10; i++) { + testArgs(f5); + testArgs(f6); + testArgs(f7); +} + +function g(){ + this.x=1 +} + +o = new g(); +assertEquals(1, o.x); +o = new g(); +assertEquals(1, o.x); +g.prototype = {y:2} +o = new g(); +assertEquals(1, o.x); +assertEquals(2, o.y); +o = new g(); +assertEquals(1, o.x); +assertEquals(2, o.y); + |