diff options
Diffstat (limited to 'js/src/tests/ecma_2/instanceof')
-rw-r--r-- | js/src/tests/ecma_2/instanceof/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/ecma_2/instanceof/instanceof-001.js | 34 | ||||
-rw-r--r-- | js/src/tests/ecma_2/instanceof/instanceof-002.js | 51 | ||||
-rw-r--r-- | js/src/tests/ecma_2/instanceof/instanceof-003.js | 65 | ||||
-rw-r--r-- | js/src/tests/ecma_2/instanceof/regress-7635.js | 55 | ||||
-rw-r--r-- | js/src/tests/ecma_2/instanceof/shell.js | 0 |
6 files changed, 205 insertions, 0 deletions
diff --git a/js/src/tests/ecma_2/instanceof/browser.js b/js/src/tests/ecma_2/instanceof/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_2/instanceof/browser.js diff --git a/js/src/tests/ecma_2/instanceof/instanceof-001.js b/js/src/tests/ecma_2/instanceof/instanceof-001.js new file mode 100644 index 000000000..9bdc7bfe3 --- /dev/null +++ b/js/src/tests/ecma_2/instanceof/instanceof-001.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: instanceof-1.js + ECMA Section: + Description: instanceof operator + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = ""; +var VERSION = "ECMA_2"; +var TITLE = "instanceof operator"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var b = new Boolean(); + +new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); + +new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); + +test(); diff --git a/js/src/tests/ecma_2/instanceof/instanceof-002.js b/js/src/tests/ecma_2/instanceof/instanceof-002.js new file mode 100644 index 000000000..6b2bb7f4f --- /dev/null +++ b/js/src/tests/ecma_2/instanceof/instanceof-002.js @@ -0,0 +1,51 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: + ECMA Section: + Description: Call Objects + + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = ""; +var VERSION = "ECMA_2"; +var TITLE = "The Call Constructor"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var b = new Boolean(); + +new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); + +new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); + +new TestCase( SECTION, + "b instanceof Array", + false, + b instanceof Array ); + +new TestCase( SECTION, + "true instanceof Boolean", + false, + true instanceof Boolean ); + +new TestCase( SECTION, + "Boolean instanceof Object", + true, + Boolean instanceof Object ); +test(); + diff --git a/js/src/tests/ecma_2/instanceof/instanceof-003.js b/js/src/tests/ecma_2/instanceof/instanceof-003.js new file mode 100644 index 000000000..1021914e9 --- /dev/null +++ b/js/src/tests/ecma_2/instanceof/instanceof-003.js @@ -0,0 +1,65 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: instanceof-003.js + ECMA Section: + Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 + + js> function Foo() {} + js> theproto = {}; + [object Object] + js> Foo.prototype = theproto + [object Object] + js> theproto instanceof Foo + true + + I think this should be 'false' + + + Author: christine@netscape.com + Date: 12 november 1997 + + Modified to conform to ECMA3 + https://bugzilla.mozilla.org/show_bug.cgi?id=281606 +*/ +var SECTION = "instanceof-003"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof operator"; +var BUGNUMBER ="7635"; + +startTest(); + +function Foo() {}; +theproto = {}; +Foo.prototype = theproto; + +AddTestCase( + "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " + + "theproto instanceof Foo", + false, + theproto instanceof Foo ); + + +var o = {}; + +// https://bugzilla.mozilla.org/show_bug.cgi?id=281606 +try +{ + AddTestCase( + "o = {}; o instanceof o", + "error", + o instanceof o ); +} +catch(e) +{ + AddTestCase( + "o = {}; o instanceof o", + "error", + "error" ); +} + +test(); diff --git a/js/src/tests/ecma_2/instanceof/regress-7635.js b/js/src/tests/ecma_2/instanceof/regress-7635.js new file mode 100644 index 000000000..7ea94e037 --- /dev/null +++ b/js/src/tests/ecma_2/instanceof/regress-7635.js @@ -0,0 +1,55 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + * File Name: regress-7635.js + * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 + * Description: instanceof tweaks + * Author: + */ + +var SECTION = "instanceof"; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA_2"; // Version of JavaScript or ECMA +var TITLE = "Regression test for Bugzilla #7635"; // Provide ECMA section title or a description +var BUGNUMBER = "7635"; // Provide URL to bugsplat or bugzilla report + +startTest(); // leave this alone + +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + +function Foo() {} +theproto = {}; +Foo.prototype = theproto + theproto instanceof Foo + + + AddTestCase( "function Foo() {}; theproto = {}; Foo.prototype = theproto; theproto instanceof Foo", + false, + theproto instanceof Foo ); + +var f = new Function(); + +AddTestCase( "var f = new Function(); f instanceof f", false, f instanceof f ); + + +test(); // leave this alone. this executes the test cases and +// displays results. diff --git a/js/src/tests/ecma_2/instanceof/shell.js b/js/src/tests/ecma_2/instanceof/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_2/instanceof/shell.js |