1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_7/geniter/regress-349331.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,95 @@ 1.4 +// |reftest| skip -- obsolete test 1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +//----------------------------------------------------------------------------- 1.11 +var BUGNUMBER = 349331; 1.12 +var summary = 'generator.close without GeneratorExit'; 1.13 +var actual = ''; 1.14 +var expect = ''; 1.15 + 1.16 + 1.17 +//----------------------------------------------------------------------------- 1.18 +test(); 1.19 +//----------------------------------------------------------------------------- 1.20 + 1.21 +function test() 1.22 +{ 1.23 + enterFunc ('test'); 1.24 + printBugNumber(BUGNUMBER); 1.25 + printStatus (summary); 1.26 + 1.27 + var catch1, catch2, catch3, finally1, finally2, finally3; 1.28 + var iter; 1.29 + 1.30 + function gen() 1.31 + { 1.32 + yield 1; 1.33 + try { 1.34 + try { 1.35 + try { 1.36 + yield 1; 1.37 + } catch (e) { 1.38 + catch1 = true; 1.39 + } finally { 1.40 + finally1 = true; 1.41 + } 1.42 + } catch (e) { 1.43 + catch2 = true; 1.44 + } finally { 1.45 + finally2 = true; 1.46 + } 1.47 + } catch (e) { 1.48 + catch3 = true; 1.49 + } finally { 1.50 + finally3 = true; 1.51 + } 1.52 + } 1.53 + 1.54 +// test explicit close call 1.55 + catch1 = catch2 = catch3 = finally1 = finally2 = finally3 = false; 1.56 + iter = gen(); 1.57 + iter.next(); 1.58 + iter.next(); 1.59 + iter.close(); 1.60 + 1.61 + var passed = !catch1 && !catch2 && !catch3 && finally1 && finally2 && 1.62 + finally3; 1.63 + 1.64 + if (!passed) { 1.65 + print("Failed!"); 1.66 + print("catch1=" + catch1 + " catch2=" + catch2 + " catch3=" + 1.67 + catch3); 1.68 + print("finally1=" + finally1 + " finally2=" + finally2 + 1.69 + " finally3=" + finally3); 1.70 + } 1.71 + 1.72 + reportCompare(true, passed, 'test explicit close call'); 1.73 + 1.74 +// test GC-invoked close 1.75 + catch1 = catch2 = catch3 = finally1 = finally2 = finally3 = false; 1.76 + iter = gen(); 1.77 + iter.next(); 1.78 + iter.next(); 1.79 + iter = null; 1.80 + gc(); 1.81 + gc(); 1.82 + 1.83 + var passed = !catch1 && !catch2 && !catch3 && finally1 && finally2 && 1.84 + finally3; 1.85 + 1.86 + if (!passed) { 1.87 + print("Failed!"); 1.88 + print("catch1=" + catch1 + " catch2=" + catch2 + " catch3=" + 1.89 + catch3); 1.90 + print("finally1=" + finally1 + " finally2=" + finally2 + 1.91 + " finally3="+finally3); 1.92 + } 1.93 + reportCompare(true, passed, 'test GC-invoke close'); 1.94 + 1.95 + reportCompare(expect, actual, summary); 1.96 + 1.97 + exitFunc ('test'); 1.98 +}