js/src/tests/js1_8_5/extensions/findReferences-03.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 // Any copyright is dedicated to the Public Domain.
     2 // http://creativecommons.org/licenses/publicdomain/
     3 // Contributor: Jim Blandy
     5 if (typeof findReferences == "function") {
     7     function makeGenerator(c) { eval(c); yield function generatorClosure() { return x; }; }
     8     var generator = makeGenerator('var x = 42');
     9     var closure = generator.next();
    10     referencesVia(closure, 'parent; generator object', generator);
    12     var o = {};
    14     assertEq(function f() {
    15 	return referencesVia(null, 'arguments', arguments) ||
    16 	       referencesVia(null, 'baseline-args-obj', arguments);
    17     }(), true);
    19     var rvalueCorrect;
    21     function finallyHoldsRval() {
    22         try {
    23             return o;
    24         } finally {
    25             rvalueCorrect = referencesVia(null, 'rval', o) ||
    26                             referencesVia(null, 'baseline-rval', o);
    27         }
    28     }
    29     rvalueCorrect = false;
    30     finallyHoldsRval();
    31     assertEq(rvalueCorrect, true);
    33     // Because we don't distinguish between JavaScript stack marking and C++
    34     // stack marking (both use the conservative scanner), we can't really write
    35     // the following tests meaningfully:
    36     //   generator frame -> generator object
    37     //   stack frame -> local variables
    38     //   stack frame -> this
    39     //   stack frame -> callee
    40     //   for(... in x) loop's reference to x
    42     reportCompare(true, true);
    43 } else {
    44     reportCompare(true, true, "test skipped: findReferences is not a function");
    45 }

mercurial