michael@0: load(libdir + "parallelarray-helpers.js"); michael@0: michael@0: function testICProto() { michael@0: function C() {} michael@0: C.prototype.foo = "foo"; michael@0: var c = new C; michael@0: assertArraySeqParResultsEq( michael@0: range(0, minItemsTestingThreshold), michael@0: "map", michael@0: function() { return c.foo; }); michael@0: } michael@0: michael@0: function f(o) { michael@0: assertArraySeqParResultsEq( michael@0: range(0, minItemsTestingThreshold), michael@0: "map", michael@0: function() { return o.foo; }); michael@0: } michael@0: michael@0: function g(o) { michael@0: assertArraySeqParResultsEq( michael@0: range(0, minItemsTestingThreshold), michael@0: "map", michael@0: function() { return o.length; }); michael@0: } michael@0: michael@0: function testICMultiple() { michael@0: var o1 = { foo: 0 }; michael@0: var o2 = { foo: 0, bar: '' }; michael@0: var o3 = { foo: 0, bar: '', baz: function () { } }; michael@0: var o4 = { foo: { } }; michael@0: f(o1); f(o2); f(o3); f(o2); f(o1); f(o4); michael@0: } michael@0: michael@0: function testICSameShapeDifferentProto() { michael@0: function A () { this.bar = 1; } michael@0: A.prototype.foo = "a"; michael@0: A.prototype.a = true; michael@0: var x = new A; michael@0: function B () { this.bar = 2; } michael@0: B.prototype.foo = "b"; michael@0: A.prototype.b = true; michael@0: var y = new B; michael@0: michael@0: f(x); michael@0: f(y); michael@0: } michael@0: michael@0: function testICArrayLength() { michael@0: var o1 = { length: 42 }; michael@0: var o2 = [1,2,3,4]; michael@0: g(o1); g(o2); michael@0: } michael@0: michael@0: function testICTypedArrayLength() { michael@0: var o1 = { length: 42 }; michael@0: var o2 = new Int8Array(128); michael@0: var o3 = new Uint8Array(128); michael@0: var o4 = new Uint8ClampedArray(128); michael@0: var o5 = new Int16Array(128); michael@0: var o6 = new Uint16Array(128); michael@0: var o7 = new Int32Array(128); michael@0: var o8 = new Uint32Array(128); michael@0: var o9 = new Float32Array(128); michael@0: var o0 = new Float64Array(128); michael@0: g(o1); g(o2); g(o3); g(o4); g(o5); g(o6); g(o7); g(o8); g(o9); g(o0); michael@0: } michael@0: michael@0: if (getBuildConfiguration().parallelJS) { michael@0: testICProto(); michael@0: testICMultiple(); michael@0: testICSameShapeDifferentProto(); michael@0: testICArrayLength(); michael@0: testICTypedArrayLength(); michael@0: }