js/src/jit-test/tests/basic/bug649939.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/basic/bug649939.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,27 @@
     1.4 +// This was the actual bug
     1.5 +assertRaises(StopIteration, function() {
     1.6 +    Iterator.prototype.next();
     1.7 +    Iterator.prototype.next();
     1.8 +});
     1.9 +
    1.10 +// The error should have triggered here, but was masked by a latent bug
    1.11 +assertRaises(StopIteration, function() {
    1.12 +    Iterator.prototype.next();
    1.13 +});
    1.14 +
    1.15 +// Found by fuzzing
    1.16 +assertRaises(StopIteration, function() {
    1.17 +    (new Iterator({})).__proto__.next();
    1.18 +});
    1.19 +
    1.20 +
    1.21 +function assertRaises(exc, callback) {
    1.22 +    var caught = false;
    1.23 +    try {
    1.24 +        callback();
    1.25 +    } catch (e) {
    1.26 +        assertEq(e instanceof StopIteration, true);
    1.27 +        caught = true;
    1.28 +    }
    1.29 +    assertEq(caught, true);
    1.30 +}

mercurial