js/src/tests/js1_7/geniter/yield-undefined.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.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //-----------------------------------------------------------------------------
     7 // Note that this syntax isn't in the most recently posted ES4 TG1 wiki export,
     8 // either in the specification parts or in the grammar, so this test might be
     9 // Spidermonkey-specific.
    10 var BUGNUMBER     = "(none)";
    11 var summary = "|yield;| is equivalent to |yield undefined;| ";
    12 var actual, expect;
    14 printBugNumber(BUGNUMBER);
    15 printStatus(summary);
    17 /**************
    18  * BEGIN TEST *
    19  **************/
    21 var failed = false;
    23 function gen()
    24 {
    25   yield 7;
    26   yield;
    27   yield 3;
    28 }
    30 var it = gen();
    32 try
    33 {
    34   if (it.next() != 7)
    35     throw "7 not yielded";
    36   if (it.next() !== undefined)
    37     throw "|yield;| should be equivalent to |yield undefined;|";
    38   if (it.next() != 3)
    39     throw "3 not yielded";
    41   var stopPassed = false;
    42   try
    43   {
    44     it.next();
    45   }
    46   catch (e)
    47   {
    48     if (e === StopIteration)
    49       stopPassed = true;
    50   }
    52   if (!stopPassed)
    53     throw "it: missing or incorrect StopIteration";
    54 }
    55 catch (e)
    56 {
    57   failed = e;
    58 }
    60 expect = false;
    61 actual = failed;
    63 reportCompare(expect, actual, summary);

mercurial