1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_7/geniter/message-value-passing.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 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 = 326466; 1.11 +var summary = "Generator value/exception passing"; 1.12 +var actual, expect; 1.13 + 1.14 +printBugNumber(BUGNUMBER); 1.15 +printStatus(summary); 1.16 + 1.17 +/************** 1.18 + * BEGIN TEST * 1.19 + **************/ 1.20 + 1.21 +function gen() 1.22 +{ 1.23 + var rv, rv2, rv3, rv4; 1.24 + rv = yield 1; 1.25 + 1.26 + if (rv) 1.27 + rv2 = yield rv; 1.28 + else 1.29 + rv3 = yield 2; 1.30 + 1.31 + try 1.32 + { 1.33 + if (rv2) 1.34 + yield rv2; 1.35 + else 1.36 + rv3 = yield 3; 1.37 + } 1.38 + catch (e) 1.39 + { 1.40 + if (e == 289) 1.41 + yield "exception caught"; 1.42 + } 1.43 + 1.44 + yield 5; 1.45 +} 1.46 + 1.47 +var failed = false; 1.48 +var it = gen(); 1.49 + 1.50 +try 1.51 +{ 1.52 + if (it.next() != 1) 1.53 + throw "failed on 1"; 1.54 + 1.55 + if (it.send(17) != 17) 1.56 + throw "failed on 17"; 1.57 + 1.58 + if (it.next() != 3) 1.59 + throw "failed on 3"; 1.60 + 1.61 + if (it.throw(289) != "exception caught") 1.62 + throw "it.throw(289) failed"; 1.63 + 1.64 + if (it.next() != 5) 1.65 + throw "failed on 5"; 1.66 + 1.67 + var stopPassed = false; 1.68 + try 1.69 + { 1.70 + it.next(); 1.71 + } 1.72 + catch (e) 1.73 + { 1.74 + if (e === StopIteration) 1.75 + stopPassed = true; 1.76 + } 1.77 + 1.78 + if (!stopPassed) 1.79 + throw "missing or incorrect StopIteration"; 1.80 +} 1.81 +catch (e) 1.82 +{ 1.83 + failed = e; 1.84 +} 1.85 + 1.86 + 1.87 + 1.88 +expect = false; 1.89 +actual = failed; 1.90 + 1.91 +reportCompare(expect, actual, summary);