Debian Codegraph @

js/src/tests/non262/statements/for-in-with-assignments.js

raw
1 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
4 */
5
6 var gTestfile = "for-in-with-assignments.js";
7 var BUGNUMBER = 1164741;
8 var summary = "Parse |for (var ... = ... in ...)|."
9
10 print(BUGNUMBER + ": " + summary);
11
12 /**************
13 * BEGIN TEST *
14 **************/
15
16 // This is a total grab-bag of junk originally in tests changed when this
17 // syntax was removed. Leaving it all in one file will make it easier to
18 // eventually remove. Avert your eyes!
19 // TC39 has revived this syntax for ES2017 - "What is dead may never die."
20
21 if (typeof Reflect !== "undefined" && Reflect.parse)
22 Reflect.parse("for (var x = 3 in []) { }");
23
24 /******************************************************************************/
25
26 function testQ() {
27 try {
28 for (var i = 0 in this) throw p;
29 } catch (e) {
30 if (i !== 94)
31 return "what";
32 }
33 }
34 testQ();
35
36 /******************************************************************************/
37
38 function f3(i,o){for(var x=i in o)parseInt(o[x]); return x}
39 function f4(i,o){with(this)for(var x=i in o)parseInt(o[x]); return x}
40
41 assertEq(f3(42, []), 42);
42 assertEq(f3(42, ['first']), "0");
43 assertEq(f4(42, []), 42);
44 assertEq(f4(42, ['first']), "0");
45
46 /******************************************************************************/
47
48 function SetLangHead(l){
49 with(p){
50 for(var i=0 in x)
51 if(getElementById("TxtH"+i)!=undefined)
52 parseInt('huh');
53 }
54 }
55 x=[0,1,2,3];
56 p={getElementById: function (id){
57 if (typeof dis === "function") {
58 dis(SetLangHead);
59 }
60 return undefined;
61 }};
62 SetLangHead(1);
63
64 /******************************************************************************/
65
66 (function(){for(var x = arguments in []){} function x(){}})();
67
68 /******************************************************************************/
69
70 with (0)
71 for (var b = 0 in 0); // don't assert in parser
72
73 /******************************************************************************/
74
75 function* g1() {
76 for (var x = yield in {}) ;
77 }
78 var it = g1();
79 assertEq(it.next().done, false);
80 assertEq(it.next().done, true);
81
82 /******************************************************************************/
83
84 if (typeof reportCompare === "function")
85 reportCompare(true, true);
86
87 print("Tests complete");