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