Changeset 43560 in webkit for trunk/JavaScriptCore/tests


Ignore:
Timestamp:
May 12, 2009, 2:18:44 AM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-05-12 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

instanceof should throw if the constructor being tested does not implement
'HasInstance" (i.e. is a function). Instead we were returning false.

  • interpreter/Interpreter.cpp: (JSC::isInvalidParamForIn): (JSC::isInvalidParamForInstanceOf): (JSC::Interpreter::privateExecute):
  • jit/JITStubs.cpp: (JSC::JITStubs::cti_op_instanceof):
  • tests/mozilla/ecma_2/instanceof/instanceof-003.js:

Fix broken test case.

  • tests/mozilla/ecma_2/instanceof/regress-7635.js:

Remove broken test case (was an exact duplicate of a test in instanceof-003.js).

LayoutTests:

2009-05-12 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Test was checked in with one test case disabled since it exposed an existing bug;
enable it now.

  • fast/js/instance-of-immediates-expected.txt:
  • fast/js/resources/instance-of-immediates.js:
Location:
trunk/JavaScriptCore/tests/mozilla/ecma_2/instanceof
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-003.js

    r11995 r43560  
    1717    Author:             [email protected]
    1818    Date:               12 november 1997
     19
     20
     21The test case described above is correct, however the second test case in this file is not,
     22'o instanceof o' should thow an exception.  According to ECMA-262:
     23
     24    8.6.2 Internal Properties and Methods:
     25        "... only Function objects implement [[HasInstance]]"
     26    11.8.6 The instanceof operator:
     27        "6.If Result(4) does not have a [[HasInstance]] method, throw a TypeError exception."
     28
     29{} does not implement [[HasInstance]] (since it is not a function), so passing it as the
     30constructor to be tested to instanceof should result in a TypeError being thrown.
     31
    1932*/
    2033    var SECTION = "instanceof-003";
     
    3649
    3750
    38     var o = {};
    39 
    4051    AddTestCase(
    4152        "o = {}; o instanceof o",
    42         false,
    43         o instanceof o );
     53        "EXCEPTION",
     54        (function(){ try { var o = {}; o instanceof o; return "no exception"; } catch (e) { return "EXCEPTION"; } } )() );
    4455
    4556
  • trunk/JavaScriptCore/tests/mozilla/ecma_2/instanceof/regress-7635.js

    r11995 r43560  
    2727 */
    2828
    29     var SECTION = "instanceof";       // provide a document reference (ie, ECMA section)
    30     var VERSION = "ECMA_2"; // Version of JavaScript or ECMA
    31     var TITLE   = "Regression test for Bugzilla #7635";       // Provide ECMA section title or a description
    32     var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7635";     // Provide URL to bugsplat or bugzilla report
     29var SECTION = "instanceof";       // provide a document reference (ie, ECMA section)
     30var VERSION = "ECMA_2"; // Version of JavaScript or ECMA
     31var TITLE   = "Regression test for Bugzilla #7635";       // Provide ECMA section title or a description
     32var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7635";     // Provide URL to bugsplat or bugzilla report
    3333
    34     startTest();               // leave this alone
     34startTest();               // leave this alone
    3535
    36     /*
    37      * Calls to AddTestCase here. AddTestCase is a function that is defined
    38      * in shell.js and takes three arguments:
    39      * - a string representation of what is being tested
    40      * - the expected result
    41      * - the actual result
    42      *
    43      * For example, a test might look like this:
    44      *
    45      * var zip = /[\d]{5}$/;
    46      *
    47      * AddTestCase(
    48      * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)",   // description of the test
    49      *  "02134",                                                           // expected result
    50      *  "PO Box 12345 Boston, MA 02134".match(zip) );                      // actual result
    51      *
    52      */
     36/*
     37 * Calls to AddTestCase here. AddTestCase is a function that is defined
     38 * in shell.js and takes three arguments:
     39 * - a string representation of what is being tested
     40 * - the expected result
     41 * - the actual result
     42 *
     43 * For example, a test might look like this:
     44 *
     45 * var zip = /[\d]{5}$/;
     46 *
     47 * AddTestCase(
     48 * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)",   // description of the test
     49 *  "02134",                                                           // expected result
     50 *  "PO Box 12345 Boston, MA 02134".match(zip) );                      // actual result
     51 *
     52 */
    5353
    54         function Foo() {}
    55         theproto = {};
    56         Foo.prototype = theproto
    57         theproto instanceof Foo
     54function Foo() {}
     55theproto = {};
     56Foo.prototype = theproto
     57theproto instanceof Foo
    5858
    5959
    60         AddTestCase( "function Foo() {}; theproto = {}; Foo.prototype = theproto; theproto instanceof Foo",
    61                         false,
    62                         theproto instanceof Foo );
    63        
    64         var o  = {};
     60AddTestCase( "function Foo() {}; theproto = {}; Foo.prototype = theproto; theproto instanceof Foo",
     61        false,
     62        theproto instanceof Foo );
    6563
    66         AddTestCase( "var o = {}; o instanceof o", false, o instanceof o );
     64var f = new Function();
    6765
    68         var f = new Function();
    69 
    70         AddTestCase( "var f = new Function(); f instanceof f", false, f instanceof f );
     66AddTestCase( "var f = new Function(); f instanceof f", false, f instanceof f );
    7167
    7268
    73     test();       // leave this alone.  this executes the test cases and
    74                   // displays results.
     69test();       // leave this alone.  this executes the test cases and
     70              // displays results.
Note: See TracChangeset for help on using the changeset viewer.