Debian Codegraph @

js/src/tests/non262/generators/regress-345855.js

raw
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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/. */
5
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 345855;
8 var summary = 'Blank yield expressions are not syntax errors';
9 var actual = '';
10 var expect = 'No Error';
11
12
13 //-----------------------------------------------------------------------------
14 test();
15 //-----------------------------------------------------------------------------
16
17 function test()
18 {
19 printBugNumber(BUGNUMBER);
20 printStatus (summary);
21
22 expect = "SyntaxError";
23 try
24 {
25 eval('(function*() {x = 12 + yield;})');
26 actual = 'No Error';
27 }
28 catch(ex)
29 {
30 actual = ex.name;
31 }
32 reportCompare(expect, actual, summary + ': function*() {x = 12 + yield;}');
33
34 expect = "SyntaxError";
35 try
36 {
37 eval('(function*() {x = 12 + yield 42})');
38 actual = 'No Error';
39 }
40 catch(ex)
41 {
42 actual = ex.name;
43 }
44 reportCompare(expect, actual, summary + ': function*() {x = 12 + yield 42}');
45
46 expect = 'No Error';
47 try
48 {
49 eval('(function*() {x = 12 + (yield);})');
50 actual = 'No Error';
51 }
52 catch(ex)
53 {
54 actual = ex + '';
55 }
56 reportCompare(expect, actual, summary + ': function*() {x = 12 + (yield);}');
57
58 try
59 {
60 eval('(function* () {foo((yield))})');
61 actual = 'No Error';
62 }
63 catch(ex)
64 {
65 actual = ex + '';
66 }
67 reportCompare(expect, actual, summary + ': function* () {foo((yield))}');
68
69 try
70 {
71 eval('(function*() {x = 12 + (yield 42)})');
72 actual = 'No Error';
73 }
74 catch(ex)
75 {
76 actual = ex + '';
77 }
78 reportCompare(expect, actual, summary + ': function*() {x = 12 + (yield 42)}');
79
80 try
81 {
82 eval('(function* (){foo((yield 42))})');
83 actual = 'No Error';
84 }
85 catch(ex)
86 {
87 actual = ex + '';
88 }
89 reportCompare(expect, actual, summary + ': function* (){foo((yield 42))}');
90 }