js/src/jit-test/tests/baseline/bug892787-2.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // Constructing calls should throw if !callee->isInterpretedConstructor().
     2 // This tests the polymorphic call path.
     4 for (var i=0; i<20; i++)
     5     Function.prototype();
     7 var funs = [
     8     function() { return 1; },
     9     function() { return 2; },
    10     function() { return 3; },
    11     function() { return 4; },
    12     function() { return 5; },
    13     function() { return 6; },
    14     function() { return 7; },
    15     function() { return 8; },
    16     function() { return 9; },
    17     function() { return 10; },
    18     Function.prototype
    19 ];
    21 function f(callee) {
    22     new callee;
    23 }
    24 function g() {
    25     var c = 0;
    26     for (var i=0; i<50; i++) {
    27 	try {
    28 	    f(funs[i % funs.length]);
    29 	} catch (e) {
    30 	    assertEq(e.message.contains("not a constructor"), true);
    31 	    c++;
    32 	}
    33     }
    34     assertEq(c, 4);
    35 }
    36 g();

mercurial