js/src/tests/js1_7/geniter/regress-349331.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial