Debian Codegraph @

rhino/testsrc/tests/js1_8/extensions/regress-394709.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-394709.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 394709;
9 var summary = 'Do not leak with object.watch and closure';
10 var actual = 'No Leak';
11 var expect = 'No Leak';
12
13 if (typeof countHeap == 'undefined')
14 {
15 countHeap = function () {
16 print('This test requires countHeap which is not supported');
17 return 0;
18 };
19 }
20
21 //-----------------------------------------------------------------------------
22 test();
23 //-----------------------------------------------------------------------------
24
25 function test()
26 {
27 enterFunc ('test');
28 printBugNumber(BUGNUMBER);
29 printStatus (summary);
30
31 runtest();
32 gc();
33 var counter = countHeap();
34 runtest();
35 gc();
36 if (counter != countHeap())
37 throw "A leaky watch point is detected";
38
39 function runtest () {
40 var obj = { b: 0 };
41 obj.watch('b', watcher);
42
43 function watcher(id, old, value) {
44 ++obj.n;
45 return value;
46 }
47 }
48
49 reportCompare(expect, actual, summary);
50
51 exitFunc ('test');
52 }