summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/instanceof
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/expressions/instanceof')
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A1.js62
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T1.js34
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T2.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T3.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T1.js22
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T2.js26
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T3.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T4.js16
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A3.js65
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T1.js25
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T2.js25
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T3.js25
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A5_T1.js46
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A5_T2.js35
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T1.js23
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T2.js23
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T3.js29
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T4.js42
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T1.js24
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T2.js24
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T3.js24
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T1.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T2.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T3.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T4.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T5.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T6.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T7.js21
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T8.js23
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T2.js32
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T5.js40
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T6.js31
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A3_T1.js30
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A3_T2.js35
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/browser.js0
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/primitive-prototype-with-object.js34
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/primitive-prototype-with-primitive.js31
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-object-throws.js44
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-object.js49
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-primitive.js36
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/shell.js0
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-get-err.js26
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-invocation.js34
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-not-callable.js26
-rw-r--r--js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-to-boolean.js46
45 files changed, 1297 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A1.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A1.js
new file mode 100644
index 0000000000..5b300bd5f6
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A1.js
@@ -0,0 +1,62 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ White Space and Line Terminator between RelationalExpression and
+ "instanceof" and between "instanceof" and ShiftExpression are allowed
+es5id: 11.8.6_A1
+description: Checking by using eval
+---*/
+
+//CHECK#1
+if (eval("({})\u0009instanceof\u0009Object") !== true) {
+ throw new Test262Error('#1: ({})\\u0009instanceof\\u0009Object === true');
+}
+
+//CHECK#2
+if (eval("({})\u000Binstanceof\u000BObject") !== true) {
+ throw new Test262Error('#2: ({})\\u000Binstanceof\\u000BObject === true');
+}
+
+//CHECK#3
+if (eval("({})\u000Cinstanceof\u000CObject") !== true) {
+ throw new Test262Error('#3: ({})\\u000Cinstanceof\\u000CObject === true');
+}
+
+//CHECK#4
+if (eval("({})\u0020instanceof\u0020Object") !== true) {
+ throw new Test262Error('#4: ({})\\u0020instanceof\\u0020Object === true');
+}
+
+//CHECK#5
+if (eval("({})\u00A0instanceof\u00A0Object") !== true) {
+ throw new Test262Error('#5: ({})\\u00A0instanceof\\u00A0Object === true');
+}
+
+//CHECK#6
+if (eval("({})\u000Ainstanceof\u000AObject") !== true) {
+ throw new Test262Error('#6: ({})\\u000Ainstanceof\\u000AObject === true');
+}
+
+//CHECK#7
+if (eval("({})\u000Dinstanceof\u000DObject") !== true) {
+ throw new Test262Error('#7: ({})\\u000Dinstanceof\\u000DObject === true');
+}
+
+//CHECK#8
+if (eval("({})\u2028instanceof\u2028Object") !== true) {
+ throw new Test262Error('#8: ({})\\u2028instanceof\\u2028Object === true');
+}
+
+//CHECK#9
+if (eval("({})\u2029instanceof\u2029Object") !== true) {
+ throw new Test262Error('#9: ({})\\u2029instanceof\\u2029Object === true');
+}
+
+//CHECK#10
+if (eval("({})\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029instanceof\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029Object") !== true) {
+ throw new Test262Error('#10: ({})\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029instanceof\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029Object === true');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T1.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T1.js
new file mode 100644
index 0000000000..5d4dd549f8
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T1.js
@@ -0,0 +1,34 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Operator "instanceof" uses GetValue
+es5id: 11.8.6_A2.1_T1
+description: Either Expression is not Reference or GetBase is not null
+---*/
+
+//CHECK#1
+if (({}) instanceof Object !== true) {
+ throw new Test262Error('#1: ({}) instanceof Object === true');
+}
+
+//CHECK#2
+var object = {};
+if (object instanceof Object !== true) {
+ throw new Test262Error('#2: var object = {}; object instanceof Object === true');
+}
+
+//CHECK#3
+var OBJECT = Object;
+if (({}) instanceof OBJECT !== true) {
+ throw new Test262Error('#3: var OBJECT = Object; ({}) instanceof OBJECT === true');
+}
+
+//CHECK#4
+var object = {};
+var OBJECT = Object;
+if (object instanceof OBJECT !== true) {
+ throw new Test262Error('#4: var object = {}; var OBJECT = Object; object instanceof OBJECT === true');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T2.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T2.js
new file mode 100644
index 0000000000..b5beec2aa3
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T2.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Operator "instanceof" uses GetValue
+es5id: 11.8.6_A2.1_T2
+description: If GetBase(RelationalExpression) is null, throw ReferenceError
+---*/
+
+//CHECK#1
+try {
+ object instanceof Object;
+ throw new Test262Error('#1.1: object instanceof Object throw ReferenceError. Actual: ' + (object instanceof Object));
+}
+catch (e) {
+ if ((e instanceof ReferenceError) !== true) {
+ throw new Test262Error('#1.2: object instanceof Object throw ReferenceError. Actual: ' + (e));
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T3.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T3.js
new file mode 100644
index 0000000000..7e6c7c9abb
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.1_T3.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Operator "instanceof" uses GetValue
+es5id: 11.8.6_A2.1_T3
+description: If GetBase(ShiftExpression) is null, throw ReferenceError
+---*/
+
+//CHECK#1
+try {
+ ({}) instanceof OBJECT;
+ throw new Test262Error('#1.1: ({}) instanceof OBJECT throw ReferenceError. Actual: ' + (({}) instanceof OBJECT));
+}
+catch (e) {
+ if ((e instanceof ReferenceError) !== true) {
+ throw new Test262Error('#1.2: ({}) instanceof OBJECT throw ReferenceError. Actual: ' + (e));
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T1.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T1.js
new file mode 100644
index 0000000000..484c95d115
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T1.js
@@ -0,0 +1,22 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: First expression is evaluated first, and then second expression
+es5id: 11.8.6_A2.4_T1
+description: Checking with "="
+---*/
+
+//CHECK#1
+var OBJECT = 0;
+if ((OBJECT = Object, {}) instanceof OBJECT !== true) {
+ throw new Test262Error('#1: var OBJECT = 0; (OBJECT = Object, {}) instanceof OBJECT === true');
+}
+
+//CHECK#2
+var object = {};
+if (object instanceof (object = 0, Object) !== true) {
+ throw new Test262Error('#2: var object = {}; object instanceof (object = 0, Object) === true');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T2.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T2.js
new file mode 100644
index 0000000000..5321562c89
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T2.js
@@ -0,0 +1,26 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: First expression is evaluated first, and then second expression
+es5id: 11.8.6_A2.4_T2
+description: Checking with "throw"
+---*/
+
+//CHECK#1
+var x = function () { throw "x"; };
+var y = function () { throw "y"; };
+try {
+ x() instanceof y();
+ throw new Test262Error('#1.1: var x = function () { throw "x"; }; var y = function () { throw "y"; }; x() instanceof y() throw "x". Actual: ' + (x() instanceof y()));
+} catch (e) {
+ if (e === "y") {
+ throw new Test262Error('#1.2: First expression is evaluated first, and then second expression');
+ } else {
+ if (e !== "x") {
+ throw new Test262Error('#1.3: var x = function () { throw "x"; }; var y = function () { throw "y"; }; x() instanceof y() throw "x". Actual: ' + (e));
+ }
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T3.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T3.js
new file mode 100644
index 0000000000..b9a29bbc04
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T3.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: First expression is evaluated first, and then second expression
+es5id: 11.8.6_A2.4_T3
+description: Checking with undeclarated variables
+---*/
+
+//CHECK#1
+try {
+ object instanceof (object = {}, Object);
+ throw new Test262Error('#1.1: object instanceof (object = {}, Object) throw ReferenceError. Actual: ' + (object instanceof (object = {}, Object)));
+}
+catch (e) {
+ if ((e instanceof ReferenceError) !== true) {
+ throw new Test262Error('#1.2: object instanceof (object = {}, Object) throw ReferenceError. Actual: ' + (e));
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T4.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T4.js
new file mode 100644
index 0000000000..3f68f87c3f
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A2.4_T4.js
@@ -0,0 +1,16 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: First expression is evaluated first, and then second expression
+es5id: 11.8.6_A2.4_T4
+description: Checking with undeclarated variables
+flags: [noStrict]
+---*/
+
+//CHECK#1
+if ((OBJECT = Object, {}) instanceof OBJECT !== true) {
+ throw new Test262Error('#1: (OBJECT = Object, {}) instanceof OBJECT !== true');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A3.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A3.js
new file mode 100644
index 0000000000..5857fdd84f
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A3.js
@@ -0,0 +1,65 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: If ShiftExpression is not an object, throw TypeError
+es5id: 11.8.6_A3
+description: Checking all the types of primitives
+---*/
+
+//CHECK#1
+try {
+ true instanceof true;
+ throw new Test262Error('#1: true instanceof true throw TypeError');
+}
+catch (e) {
+ if (e instanceof TypeError !== true) {
+ throw new Test262Error('#1: true instanceof true throw TypeError');
+ }
+}
+
+//CHECK#2
+try {
+ 1 instanceof 1;
+ throw new Test262Error('#2: 1 instanceof 1 throw TypeError');
+}
+catch (e) {
+ if (e instanceof TypeError !== true) {
+ throw new Test262Error('#2: 1 instanceof 1 throw TypeError');
+ }
+}
+
+//CHECK#3
+try {
+ "string" instanceof "string";
+ throw new Test262Error('#3: "string" instanceof "string" throw TypeError');
+}
+catch (e) {
+ if (e instanceof TypeError !== true) {
+ throw new Test262Error('#3: "string" instanceof "string" throw TypeError');
+ }
+}
+
+//CHECK#4
+try {
+ undefined instanceof undefined;
+ throw new Test262Error('#4: undefined instanceof undefined throw TypeError');
+}
+catch (e) {
+ if (e instanceof TypeError !== true) {
+ throw new Test262Error('#4: undefined instanceof undefined throw TypeError');
+ }
+}
+
+//CHECK#5
+try {
+ null instanceof null;
+ throw new Test262Error('#5: null instanceof null throw TypeError');
+}
+catch (e) {
+ if (e instanceof TypeError !== true) {
+ throw new Test262Error('#5: null instanceof null throw TypeError');
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T1.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T1.js
new file mode 100644
index 0000000000..f0e7e51296
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T1.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Only constructor call (with "new" keyword) makes instance
+es5id: 11.8.6_A4_T1
+description: Checking Boolean case
+---*/
+
+//CHECK#1
+if (false instanceof Boolean) {
+ throw new Test262Error('#1: false is not instanceof Boolean');
+}
+
+//CHECK#2
+if (Boolean(false) instanceof Boolean) {
+ throw new Test262Error('#2: Boolean(false) is not instanceof Boolean');
+}
+
+//CHECK#3
+if (new Boolean instanceof Boolean !== true) {
+ throw new Test262Error('#3: new Boolean instanceof Boolean');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T2.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T2.js
new file mode 100644
index 0000000000..a37e0c0011
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T2.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Only constructor call (with "new" keyword) makes instance
+es5id: 11.8.6_A4_T2
+description: Checking Number case
+---*/
+
+//CHECK#1
+if (0 instanceof Number) {
+ throw new Test262Error('#1: 0 is not instanceof Number');
+}
+
+//CHECK#2
+if (Number(0) instanceof Number) {
+ throw new Test262Error('#2: Number(0) is not instanceof Number');
+}
+
+//CHECK#3
+if (new Number instanceof Number !== true) {
+ throw new Test262Error('#3: new Number instanceof Number');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T3.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T3.js
new file mode 100644
index 0000000000..cd8fd0e05a
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A4_T3.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Only constructor call (with "new" keyword) makes instance
+es5id: 11.8.6_A4_T3
+description: Checking String case
+---*/
+
+//CHECK#1
+if ("" instanceof String) {
+ throw new Test262Error('#1: "" is not instanceof String');
+}
+
+//CHECK#2
+if (String("") instanceof String) {
+ throw new Test262Error('#2: String("") is not instanceof String');
+}
+
+//CHECK#3
+if (new String instanceof String !== true) {
+ throw new Test262Error('#3: new String instanceof String');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A5_T1.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A5_T1.js
new file mode 100644
index 0000000000..b8055648b5
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A5_T1.js
@@ -0,0 +1,46 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: TypeError is subclass of Error from instanceof operator point of view
+es5id: 11.8.6_A5_T1
+description: Checking Error case
+---*/
+
+var __err = new Error;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (!(__err instanceof Error)) {
+ throw new Test262Error('#1: TypeError is subclass of Error from instanceof operator point of view');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__err instanceof TypeError) {
+ throw new Test262Error('#2: TypeError is subclass of Error from instanceof operator point of view');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+var err__ = Error('failed');
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+if (!(err__ instanceof Error)) {
+ throw new Test262Error('#3: TypeError is subclass of Error from instanceof operator point of view');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#4
+if (err__ instanceof TypeError) {
+ throw new Test262Error('#4: TypeError is subclass of Error from instanceof operator point of view');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A5_T2.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A5_T2.js
new file mode 100644
index 0000000000..8ecfa573cf
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A5_T2.js
@@ -0,0 +1,35 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: TypeError is subclass of Error from instanceof operator point of view
+es5id: 11.8.6_A5_T2
+description: Checking TypeError case
+---*/
+
+var __t__err = new TypeError;
+
+//CHECK#1
+if (!(__t__err instanceof Error)) {
+ throw new Test262Error('#1: TypeError is subclass of Error from instanceof operator point of view');
+}
+
+//CHECK#2
+if (!(__t__err instanceof TypeError)) {
+ throw new Test262Error('#2: TypeError is subclass of Error from instanceof operator point of view');
+}
+
+//////////////////////////////////////////////////////////////////////////////
+var err__t__ = TypeError('failed');
+
+//CHECK#3
+if (!(err__t__ instanceof Error)) {
+ throw new Test262Error('#3: TypeError is subclass of Error from instanceof operator point of view');
+}
+
+//CHECK#4
+if (!(err__t__ instanceof TypeError)) {
+ throw new Test262Error('#4: TypeError is subclass of Error from instanceof operator point of view');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T1.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T1.js
new file mode 100644
index 0000000000..1897ee35c8
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T1.js
@@ -0,0 +1,23 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Only Function objects implement [[HasInstance]] and can be proper
+ ShiftExpression for the "instanceof" operator consequently
+es5id: 11.8.6_A6_T1
+description: Checking "this" case
+---*/
+
+//CHECK#1
+try{
+ ({}) instanceof this;
+ throw new Test262Error('#1: Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator');
+}
+catch(e){
+ if (e instanceof TypeError !== true) {
+ throw new Test262Error('#1: Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator');
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T2.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T2.js
new file mode 100644
index 0000000000..6752c71839
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T2.js
@@ -0,0 +1,23 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Only Function objects implement [[HasInstance]] and can be proper
+ ShiftExpression for the "instanceof" operator consequently
+es5id: 11.8.6_A6_T2
+description: Checking Math case
+---*/
+
+//CHECK#1
+try{
+ 1 instanceof Math;
+ throw new Test262Error('#1: 1 instanceof Math throw TypeError');
+}
+catch(e){
+ if (e instanceof TypeError !== true) {
+ throw new Test262Error('#1: 1 instanceof Math throw TypeError');
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T3.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T3.js
new file mode 100644
index 0000000000..96cc036457
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T3.js
@@ -0,0 +1,29 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Only Function objects implement [[HasInstance]] and can be proper
+ ShiftExpression for the "instanceof" operator consequently
+es5id: 11.8.6_A6_T3
+description: Checking if RelationalExpression is function
+---*/
+
+function MyFunct(){return 0};
+
+//CHECK#1
+if (MyFunct instanceof MyFunct){
+ throw new Test262Error('#1 function MyFunct(){return 0}; MyFunct instanceof MyFunct === false');
+}
+
+//CHECK#2
+if (MyFunct instanceof Function !== true){
+ throw new Test262Error('#2 function MyFunct(){return 0}; MyFunct instanceof Function === true');
+}
+
+//CHECK#3
+if (MyFunct instanceof Object !== true){
+ throw new Test262Error('#3 function MyFunct(){return 0}; MyFunct instanceof Object === true');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T4.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T4.js
new file mode 100644
index 0000000000..f72e4a43f8
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A6_T4.js
@@ -0,0 +1,42 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Only Function objects implement [[HasInstance]] and can be proper
+ ShiftExpression for the "instanceof" operator consequently
+es5id: 11.8.6_A6_T4
+description: Checking if RelationalExpression is object
+---*/
+
+var MyFunct = function(){};
+var __my__funct = new MyFunct;
+
+
+//CHECK#1
+if (!(__my__funct instanceof MyFunct)){
+ throw new Test262Error('#1 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator');
+}
+
+//CHECK#2
+if (__my__funct instanceof Function){
+ throw new Test262Error('#2 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator');
+}
+
+//CHECK#3
+if (!(__my__funct instanceof Object)){
+ throw new Test262Error('#3 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator');
+}
+
+//CHECK#4
+try{
+ __my__funct instanceof __my__funct;
+ throw new Test262Error('#4 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator');
+}
+catch(e){
+ if (e instanceof TypeError !== true) {
+ throw new Test262Error('#4 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator');
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T1.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T1.js
new file mode 100644
index 0000000000..842d23762c
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T1.js
@@ -0,0 +1,24 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ When "instanceof" returns true it means that
+ GetValue(RelationalExpression) is constructed with ShiftExpression
+es5id: 11.8.6_A7_T1
+description: Checking Object object
+---*/
+
+var __obj={};
+
+//CHECK#1
+if (!(__obj instanceof Object)) {
+ throw new Test262Error('#1: If instanceof returns true then GetValue(RelationalExpression) was constructed with ShiftExpression');
+}
+
+//CHECK#2
+if (__obj.constructor !== Object) {
+ throw new Test262Error('#2: If instanceof returns true then GetValue(RelationalExpression) was constructed with ShiftExpression');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T2.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T2.js
new file mode 100644
index 0000000000..e27c76e779
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T2.js
@@ -0,0 +1,24 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ When "instanceof" returns true it means that
+ GetValue(RelationalExpression) is constructed with ShiftExpression
+es5id: 11.8.6_A7_T2
+description: Checking Array object
+---*/
+
+var __arr=[];
+
+//CHECK#1
+if (!(__arr instanceof Array)) {
+ throw new Test262Error('#1: If instanceof returns true then GetValue(RelationalExpression) was constructed with ShiftExpression');
+}
+
+//CHECK#2
+if (__arr.constructor !== Array) {
+ throw new Test262Error('#2: If instanceof returns true then GetValue(RelationalExpression) was constructed with ShiftExpression');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T3.js b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T3.js
new file mode 100644
index 0000000000..17b80eae7b
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S11.8.6_A7_T3.js
@@ -0,0 +1,24 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ When "instanceof" returns true it means that
+ GetValue(RelationalExpression) is constructed with ShiftExpression
+es5id: 11.8.6_A7_T3
+description: Checking Function object
+---*/
+
+var __func = new Function;
+
+//CHECK#1
+if (!(__func instanceof Function)) {
+ throw new Test262Error('#1: If instanceof returns true then GetValue(RelationalExpression) was constructed with ShiftExpression');
+}
+
+//CHECK#2
+if (__func.constructor !== Function) {
+ throw new Test262Error('#2: If instanceof returns true then GetValue(RelationalExpression) was constructed with ShiftExpression');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T1.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T1.js
new file mode 100644
index 0000000000..254bb0fec9
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T1.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is
+ called with value V, the following steps are taken: i) If V is not an
+ object, return false
+es5id: 15.3.5.3_A1_T1
+description: V is number
+---*/
+
+var FACTORY;
+FACTORY = Function("name","this.name=name;");
+
+//CHECK#1
+if ((1 instanceof FACTORY)!==false) {
+ throw new Test262Error('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T2.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T2.js
new file mode 100644
index 0000000000..f533326181
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T2.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is
+ called with value V, the following steps are taken: i) If V is not an
+ object, return false
+es5id: 15.3.5.3_A1_T2
+description: V is string
+---*/
+
+var FACTORY;
+FACTORY = Function("name","this.name=name;");
+
+//CHECK#1
+if (("1" instanceof FACTORY)!==false) {
+ throw new Test262Error('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T3.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T3.js
new file mode 100644
index 0000000000..6ff9336099
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T3.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is
+ called with value V, the following steps are taken: i) If V is not an
+ object, return false
+es5id: 15.3.5.3_A1_T3
+description: V is boolean true
+---*/
+
+var FACTORY;
+FACTORY = Function("name","this.name=name;");
+
+//CHECK#1
+if ((true instanceof FACTORY)!==false) {
+ throw new Test262Error('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T4.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T4.js
new file mode 100644
index 0000000000..f326d90b9d
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T4.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is
+ called with value V, the following steps are taken: i) If V is not an
+ object, return false
+es5id: 15.3.5.3_A1_T4
+description: V is boolean false
+---*/
+
+var FACTORY;
+FACTORY = Function("name","this.name=name;");
+
+//CHECK#1
+if ((false instanceof FACTORY)!==false) {
+ throw new Test262Error('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T5.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T5.js
new file mode 100644
index 0000000000..5ea46544db
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T5.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is
+ called with value V, the following steps are taken: i) If V is not an
+ object, return false
+es5id: 15.3.5.3_A1_T5
+description: V is void 0
+---*/
+
+var FACTORY;
+FACTORY = Function("name","this.name=name;");
+
+//CHECK#1
+if ((void 0 instanceof FACTORY)!==false) {
+ throw new Test262Error('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T6.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T6.js
new file mode 100644
index 0000000000..5cf1da10d0
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T6.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is
+ called with value V, the following steps are taken: i) If V is not an
+ object, return false
+es5id: 15.3.5.3_A1_T6
+description: V is null
+---*/
+
+var FACTORY;
+FACTORY = Function("name","this.name=name;");
+
+//CHECK#1
+if ((null instanceof FACTORY)!==false) {
+ throw new Test262Error('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T7.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T7.js
new file mode 100644
index 0000000000..940d51c3ff
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T7.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is
+ called with value V, the following steps are taken: i) If V is not an
+ object, return false
+es5id: 15.3.5.3_A1_T7
+description: V is undefined
+---*/
+
+var FACTORY;
+FACTORY = Function("name","this.name=name;");
+
+//CHECK#1
+if ((undefined instanceof FACTORY)!==false) {
+ throw new Test262Error('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T8.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T8.js
new file mode 100644
index 0000000000..38f4897df5
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A1_T8.js
@@ -0,0 +1,23 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is
+ called with value V, the following steps are taken: i) If V is not an
+ object, return false
+es5id: 15.3.5.3_A1_T8
+description: V is undefined variable
+---*/
+
+var FACTORY;
+FACTORY = Function("name","this.name=name;");
+
+//CHECK#1
+if ((x instanceof FACTORY)!==false) {
+ throw new Test262Error('#1: Assume F is a Function object. When the [[HasInstance]] method of F is called with value V, the following steps are taken: i) If V is not an object, return false');
+}
+
+var x;
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T2.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T2.js
new file mode 100644
index 0000000000..e1deedadec
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T2.js
@@ -0,0 +1,32 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is called with value V and V is an object, the following steps are taken:
+ i) Call the [[Get]] method of F with property name "prototype".
+ ii) Let O be Result(i).
+ iii) O is not an object, throw a TypeError exception
+es5id: 15.3.5.3_A2_T2
+description: F.prototype is undefined, and V is empty object
+---*/
+
+var FACTORY;
+FACTORY = new Function;
+
+FACTORY.prototype = undefined;
+
+var obj;
+obj={};
+
+//CHECK#1
+try {
+ obj instanceof FACTORY;
+ throw new Test262Error('#1: O is not an object, throw a TypeError exception');
+} catch (e) {
+ if (!(e instanceof TypeError)) {
+ throw new Test262Error('#1.1: O is not an object, throw a TypeError exception');
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T5.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T5.js
new file mode 100644
index 0000000000..0304818c15
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T5.js
@@ -0,0 +1,40 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of
+ F is called with value V and V is an object, the following steps
+ are taken: i) Call the [[Get]] method of F with property name
+ "prototype". ii) Let O be Result(i). iii) O is not an object,
+ throw a TypeError exception
+es5id: 15.3.5.3_A2_T5
+description: F.prototype is void 0, and V is new F
+---*/
+
+var FACTORY;
+FACTORY = Function("this.prop=1;");
+
+FACTORY.prototype.name = "fairy";
+
+var instance;
+instance = new FACTORY;
+
+FACTORY.prototype = void 0;
+
+// CHECK#1
+try {
+ instance instanceof FACTORY;
+ throw new Test262Error('#1: O is not an object, throw a TypeError exception');
+} catch (e) {
+ if (!(e instanceof TypeError)) {
+ throw new Test262Error('#1.1: O is not an object, throw a TypeError exception');
+ }
+}
+
+// CHECK#2
+if ((instance.constructor !== FACTORY) || (instance.name !== "fairy")) {
+ throw new Test262Error('#2: instance.constructor === FACTORY');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T6.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T6.js
new file mode 100644
index 0000000000..602bf2a033
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A2_T6.js
@@ -0,0 +1,31 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of
+ F is called with value V and V is an object, the following steps
+ are taken: i) Call the [[Get]] method of F with property name
+ "prototype". ii) Let O be Result(i). iii) O is not an object,
+ throw a TypeError exception
+es5id: 15.3.5.3_A2_T6
+description: F.prototype is string, and V is function
+---*/
+
+var FACTORY;
+FACTORY = new Function;
+
+FACTORY.prototype = "error";
+
+// CHECK#1
+try {
+ ( function() {
+ }) instanceof FACTORY;
+ throw new Test262Error('#1: O is not an object, throw a TypeError exception');
+} catch (e) {
+ if (!(e instanceof TypeError)) {
+ throw new Test262Error('#1.1: O is not an object, throw a TypeError exception');
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A3_T1.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A3_T1.js
new file mode 100644
index 0000000000..a560afc77a
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A3_T1.js
@@ -0,0 +1,30 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is called with value V and V is an object, the following steps are taken:
+ i) Call the [[Get]] method of F with property name "prototype".
+ ii) Let O be Result(i) and O is an object.
+ iii) Let V be the value of the [[Prototype]] property of V.
+ iv) If V is null, return false.
+ v) If O and V refer to the same object or if they refer to objects joined to each other (13.1.2), return true.
+ vi) Go to step iii)
+es5id: 15.3.5.3_A3_T1
+description: F.prototype.type is 1, and V is new F
+---*/
+
+var FACTORY;
+FACTORY = Function("this.name=\"root\"");
+
+FACTORY.prototype.type=1;
+
+var instance;
+instance = new FACTORY;
+
+//CHECK#1
+if (!(instance instanceof FACTORY)) {
+ throw new Test262Error('#1: If O and V refer to the same object or if they refer to objects joined to each other (13.1.2), return true');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A3_T2.js b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A3_T2.js
new file mode 100644
index 0000000000..f4eea724ca
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/S15.3.5.3_A3_T2.js
@@ -0,0 +1,35 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Assume F is a Function object. When the [[HasInstance]] method of F is called with value V and V is an object, the following steps are taken:
+ i) Call the [[Get]] method of F with property name "prototype".
+ ii) Let O be Result(i) and O is an object.
+ iii) Let V be the value of the [[Prototype]] property of V.
+ iv) If V is null, return false.
+ v) If O and V refer to the same object or if they refer to objects joined to each other (13.1.2), return true.
+ vi) Go to step iii)
+es5id: 15.3.5.3_A3_T2
+description: F.prototype is Object.prototype, and V is empty object
+---*/
+
+var FAKEFACTORY;
+FAKEFACTORY = Function();
+
+var fakeinstance;
+fakeinstance = {};
+
+//CHECK#1
+if (fakeinstance instanceof FAKEFACTORY) {
+ throw new Test262Error('#1: If O and V refer to the same object or if they refer to objects joined to each other (13.1.2), return true');
+}
+
+FAKEFACTORY.prototype=Object.prototype;
+
+//CHECK#2
+if (!(fakeinstance instanceof FAKEFACTORY)) {
+ throw new Test262Error('#2: If O and V refer to the same object or if they refer to objects joined to each other (13.1.2), return true');
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/browser.js b/js/src/tests/test262/language/expressions/instanceof/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/browser.js
diff --git a/js/src/tests/test262/language/expressions/instanceof/primitive-prototype-with-object.js b/js/src/tests/test262/language/expressions/instanceof/primitive-prototype-with-object.js
new file mode 100644
index 0000000000..38ee7a8be7
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/primitive-prototype-with-object.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.3
+description: >
+ Throws a TypeError if `prototype` property is not an Object.
+info: |
+ 12.9.3 Runtime Semantics: Evaluation
+ RelationalExpression : RelationalExpression instanceof ShiftExpression
+ ...
+ 7. Return InstanceofOperator(lval, rval).
+
+ 12.9.4 Runtime Semantics: InstanceofOperator(O, C)
+ ...
+ 6. Return OrdinaryHasInstance(C, O).
+
+ 7.3.19 OrdinaryHasInstance
+ ...
+ 3. If Type(O) is not Object, return false.
+ 4. Let P be Get(C, "prototype").
+ 5. ReturnIfAbrupt(P).
+ 6. If Type(P) is not Object, throw a TypeError exception.
+ ...
+---*/
+
+// Check with primitive "prototype" property on non-constructor function.
+Function.prototype.prototype = "";
+
+assert.throws(TypeError, function() {
+ [] instanceof Function.prototype;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/primitive-prototype-with-primitive.js b/js/src/tests/test262/language/expressions/instanceof/primitive-prototype-with-primitive.js
new file mode 100644
index 0000000000..53ca25f50a
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/primitive-prototype-with-primitive.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.3
+description: >
+ Does not throw a TypeError if left-hand side expression and `prototype` property are both primitive values.
+info: |
+ 12.9.3 Runtime Semantics: Evaluation
+ RelationalExpression : RelationalExpression instanceof ShiftExpression
+ ...
+ 7. Return InstanceofOperator(lval, rval).
+
+ 12.9.4 Runtime Semantics: InstanceofOperator(O, C)
+ ...
+ 6. Return OrdinaryHasInstance(C, O).
+
+ 7.3.19 OrdinaryHasInstance
+ ...
+ 3. If Type(O) is not Object, return false.
+ ...
+---*/
+
+// Check with primitive "prototype" property on non-constructor function.
+Function.prototype.prototype = true;
+
+var result = 0 instanceof Function.prototype;
+
+assert.sameValue(result, false);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-object-throws.js b/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-object-throws.js
new file mode 100644
index 0000000000..a7100ae431
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-object-throws.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.3
+description: >
+ "prototype" property is retrieved when left-hand side expression in `instanceof` is object.
+info: |
+ 12.9.3 Runtime Semantics: Evaluation
+ RelationalExpression : RelationalExpression instanceof ShiftExpression
+ ...
+ 7. Return InstanceofOperator(lval, rval).
+
+ 12.9.4 Runtime Semantics: InstanceofOperator(O, C)
+ ...
+ 6. Return OrdinaryHasInstance(C, O).
+
+ 7.3.19 OrdinaryHasInstance
+ ...
+ 3. If Type(O) is not Object, return false.
+ 4. Let P be Get(C, "prototype").
+ 5. ReturnIfAbrupt(P).
+ ...
+---*/
+
+var getterCalled = false;
+
+function DummyError() { }
+
+// The "prototype" property for constructor functions is a non-configurable data-property,
+// therefore we need to use a non-constructor function to install the getter.
+Object.defineProperty(Function.prototype, "prototype", {
+ get: function() {
+ assert.sameValue(getterCalled, false, "'prototype' getter called once");
+ getterCalled = true;
+ throw new DummyError();
+ }
+});
+
+assert.throws(DummyError, function() {
+ [] instanceof Function.prototype;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-object.js b/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-object.js
new file mode 100644
index 0000000000..a26c3e67f6
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-object.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.3
+description: >
+ "prototype" property is retrieved when left-hand side expression in `instanceof` is object.
+info: |
+ 12.9.3 Runtime Semantics: Evaluation
+ RelationalExpression : RelationalExpression instanceof ShiftExpression
+ ...
+ 7. Return InstanceofOperator(lval, rval).
+
+ 12.9.4 Runtime Semantics: InstanceofOperator(O, C)
+ ...
+ 6. Return OrdinaryHasInstance(C, O).
+
+ 7.3.19 OrdinaryHasInstance
+ ...
+ 3. If Type(O) is not Object, return false.
+ 4. Let P be Get(C, "prototype").
+ 5. ReturnIfAbrupt(P).
+ 6. If Type(P) is not Object, throw a TypeError exception.
+ 7. Repeat
+ a. Let O be O.[[GetPrototypeOf]]().
+ b. ReturnIfAbrupt(O).
+ c. If O is null, return false.
+ d. If SameValue(P, O) is true, return true.
+ ...
+---*/
+
+var getterCalled = false;
+
+// The "prototype" property for constructor functions is a non-configurable data-property,
+// therefore we need to use a non-constructor function to install the getter.
+Object.defineProperty(Function.prototype, "prototype", {
+ get: function() {
+ assert.sameValue(getterCalled, false, "'prototype' getter called once");
+ getterCalled = true;
+ return Array.prototype;
+ }
+});
+
+var result = [] instanceof Function.prototype;
+
+assert(result, "[] should be instance of Function.prototype");
+assert(getterCalled, "'prototype' getter called");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-primitive.js b/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-primitive.js
new file mode 100644
index 0000000000..e37cfec7c8
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/prototype-getter-with-primitive.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.3
+description: >
+ "prototype" property is not retrieved when left-hand side expression in `instanceof` is primitive.
+info: |
+ 12.9.3 Runtime Semantics: Evaluation
+ RelationalExpression : RelationalExpression instanceof ShiftExpression
+ ...
+ 7. Return InstanceofOperator(lval, rval).
+
+ 12.9.4 Runtime Semantics: InstanceofOperator(O, C)
+ ...
+ 6. Return OrdinaryHasInstance(C, O).
+
+ 7.3.19 OrdinaryHasInstance
+ ...
+ 3. If Type(O) is not Object, return false.
+ ...
+---*/
+
+// The "prototype" property for constructor functions is a non-configurable data-property,
+// therefore we need to use a non-constructor function to install the getter.
+Object.defineProperty(Function.prototype, "prototype", {
+ get: function() {
+ throw new Test262Error("getter for 'prototype' called");
+ }
+});
+
+var result = 0 instanceof Function.prototype;
+
+assert.sameValue(result, false);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/shell.js b/js/src/tests/test262/language/expressions/instanceof/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/shell.js
diff --git a/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-get-err.js b/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-get-err.js
new file mode 100644
index 0000000000..e562e9c4ff
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-get-err.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.4
+description: Error thrown when accessing constructor's @@hasInstance property
+info: |
+ 1. If Type(C) is not Object, throw a TypeError exception.
+ 2. Let instOfHandler be GetMethod(C,@@hasInstance).
+ 3. ReturnIfAbrupt(instOfHandler).
+features: [Symbol.hasInstance]
+---*/
+
+var F = {};
+
+Object.defineProperty(F, Symbol.hasInstance, {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ 0 instanceof F;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-invocation.js b/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-invocation.js
new file mode 100644
index 0000000000..bc0a56e9c1
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-invocation.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.4
+description: >
+ Arguments and 'this' value when invoking constructor's @@hasInstance property
+info: |
+ 1. If Type(C) is not Object, throw a TypeError exception.
+ 2. Let instOfHandler be GetMethod(C,@@hasInstance).
+ 3. ReturnIfAbrupt(instOfHandler).
+ 4. If instOfHandler is not undefined, then
+ a. Return ToBoolean(Call(instOfHandler, C, «O»)).
+features: [Symbol.hasInstance]
+---*/
+
+var F = {};
+var callCount = 0;
+var thisValue, args;
+
+F[Symbol.hasInstance] = function() {
+ thisValue = this;
+ args = arguments;
+ callCount += 1;
+};
+
+0 instanceof F;
+
+assert.sameValue(callCount, 1);
+assert.sameValue(thisValue, F);
+assert.sameValue(args.length, 1);
+assert.sameValue(args[0], 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-not-callable.js b/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-not-callable.js
new file mode 100644
index 0000000000..4059b662c1
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-not-callable.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.4
+description: >
+ Error thrown when constructor's @@hasInstance property is defined but not callable
+info: |
+ 1. If Type(C) is not Object, throw a TypeError exception.
+ 2. Let instOfHandler be GetMethod(C,@@hasInstance).
+ 3. ReturnIfAbrupt(instOfHandler).
+ 4. If instOfHandler is not undefined, then
+ a. Return ToBoolean(Call(instOfHandler, C, «O»)).
+ 5. If IsCallable(C) is false, throw a TypeError exception.
+features: [Symbol.hasInstance]
+---*/
+
+var F = {};
+
+F[Symbol.hasInstance] = null;
+
+assert.throws(TypeError, function() {
+ 0 instanceof F;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-to-boolean.js b/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-to-boolean.js
new file mode 100644
index 0000000000..195ac80ad1
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/instanceof/symbol-hasinstance-to-boolean.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 12.9.4
+description: >
+ Type coercion of value returned by constructor's @@hasInstance property
+info: |
+ 1. If Type(C) is not Object, throw a TypeError exception.
+ 2. Let instOfHandler be GetMethod(C,@@hasInstance).
+ 3. ReturnIfAbrupt(instOfHandler).
+ 4. If instOfHandler is not undefined, then
+ a. Return ToBoolean(Call(instOfHandler, C, «O»)).
+features: [Symbol, Symbol.hasInstance]
+---*/
+
+var F = {};
+
+F[Symbol.hasInstance] = function() { return undefined; };
+assert.sameValue(0 instanceof F, false);
+
+F[Symbol.hasInstance] = function() { return null; };
+assert.sameValue(0 instanceof F, false);
+
+F[Symbol.hasInstance] = function() { return true; };
+assert.sameValue(0 instanceof F, true);
+
+F[Symbol.hasInstance] = function() { return NaN; };
+assert.sameValue(0 instanceof F, false);
+
+F[Symbol.hasInstance] = function() { return 1; };
+assert.sameValue(0 instanceof F, true);
+
+F[Symbol.hasInstance] = function() { return ''; };
+assert.sameValue(0 instanceof F, false);
+
+F[Symbol.hasInstance] = function() { return 'string'; };
+assert.sameValue(0 instanceof F, true);
+
+F[Symbol.hasInstance] = function() { return Symbol(); };
+assert.sameValue(0 instanceof F, true);
+
+F[Symbol.hasInstance] = function() { return {}; };
+assert.sameValue(0 instanceof F, true);
+
+reportCompare(0, 0);