|
1 // |reftest| skip -- obsolete test |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 //----------------------------------------------------------------------------- |
|
8 var BUGNUMBER = 349331; |
|
9 var summary = 'generator.close without GeneratorExit'; |
|
10 var actual = ''; |
|
11 var expect = ''; |
|
12 |
|
13 |
|
14 //----------------------------------------------------------------------------- |
|
15 test(); |
|
16 //----------------------------------------------------------------------------- |
|
17 |
|
18 function test() |
|
19 { |
|
20 enterFunc ('test'); |
|
21 printBugNumber(BUGNUMBER); |
|
22 printStatus (summary); |
|
23 |
|
24 var catch1, catch2, catch3, finally1, finally2, finally3; |
|
25 var iter; |
|
26 |
|
27 function gen() |
|
28 { |
|
29 yield 1; |
|
30 try { |
|
31 try { |
|
32 try { |
|
33 yield 1; |
|
34 } catch (e) { |
|
35 catch1 = true; |
|
36 } finally { |
|
37 finally1 = true; |
|
38 } |
|
39 } catch (e) { |
|
40 catch2 = true; |
|
41 } finally { |
|
42 finally2 = true; |
|
43 } |
|
44 } catch (e) { |
|
45 catch3 = true; |
|
46 } finally { |
|
47 finally3 = true; |
|
48 } |
|
49 } |
|
50 |
|
51 // test explicit close call |
|
52 catch1 = catch2 = catch3 = finally1 = finally2 = finally3 = false; |
|
53 iter = gen(); |
|
54 iter.next(); |
|
55 iter.next(); |
|
56 iter.close(); |
|
57 |
|
58 var passed = !catch1 && !catch2 && !catch3 && finally1 && finally2 && |
|
59 finally3; |
|
60 |
|
61 if (!passed) { |
|
62 print("Failed!"); |
|
63 print("catch1=" + catch1 + " catch2=" + catch2 + " catch3=" + |
|
64 catch3); |
|
65 print("finally1=" + finally1 + " finally2=" + finally2 + |
|
66 " finally3=" + finally3); |
|
67 } |
|
68 |
|
69 reportCompare(true, passed, 'test explicit close call'); |
|
70 |
|
71 // test GC-invoked close |
|
72 catch1 = catch2 = catch3 = finally1 = finally2 = finally3 = false; |
|
73 iter = gen(); |
|
74 iter.next(); |
|
75 iter.next(); |
|
76 iter = null; |
|
77 gc(); |
|
78 gc(); |
|
79 |
|
80 var passed = !catch1 && !catch2 && !catch3 && finally1 && finally2 && |
|
81 finally3; |
|
82 |
|
83 if (!passed) { |
|
84 print("Failed!"); |
|
85 print("catch1=" + catch1 + " catch2=" + catch2 + " catch3=" + |
|
86 catch3); |
|
87 print("finally1=" + finally1 + " finally2=" + finally2 + |
|
88 " finally3="+finally3); |
|
89 } |
|
90 reportCompare(true, passed, 'test GC-invoke close'); |
|
91 |
|
92 reportCompare(expect, actual, summary); |
|
93 |
|
94 exitFunc ('test'); |
|
95 } |