michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: // Contributor: Jim Blandy michael@0: michael@0: if (typeof findReferences == "function") { michael@0: michael@0: function makeGenerator(c) { eval(c); yield function generatorClosure() { return x; }; } michael@0: var generator = makeGenerator('var x = 42'); michael@0: var closure = generator.next(); michael@0: referencesVia(closure, 'parent; generator object', generator); michael@0: michael@0: var o = {}; michael@0: michael@0: assertEq(function f() { michael@0: return referencesVia(null, 'arguments', arguments) || michael@0: referencesVia(null, 'baseline-args-obj', arguments); michael@0: }(), true); michael@0: michael@0: var rvalueCorrect; michael@0: michael@0: function finallyHoldsRval() { michael@0: try { michael@0: return o; michael@0: } finally { michael@0: rvalueCorrect = referencesVia(null, 'rval', o) || michael@0: referencesVia(null, 'baseline-rval', o); michael@0: } michael@0: } michael@0: rvalueCorrect = false; michael@0: finallyHoldsRval(); michael@0: assertEq(rvalueCorrect, true); michael@0: michael@0: // Because we don't distinguish between JavaScript stack marking and C++ michael@0: // stack marking (both use the conservative scanner), we can't really write michael@0: // the following tests meaningfully: michael@0: // generator frame -> generator object michael@0: // stack frame -> local variables michael@0: // stack frame -> this michael@0: // stack frame -> callee michael@0: // for(... in x) loop's reference to x michael@0: michael@0: reportCompare(true, true); michael@0: } else { michael@0: reportCompare(true, true, "test skipped: findReferences is not a function"); michael@0: }