| 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 = 321874; |
| 8 |
var summary = 'lhs must be a reference in (for lhs in rhs) ...'; |
| 9 |
var actual = ''; |
| 10 |
var expect = ''; |
| 11 |
var section; |
| 12 |
|
| 13 |
printBugNumber(BUGNUMBER); |
| 14 |
printStatus (summary); |
| 15 |
|
| 16 |
function a() {} |
| 17 |
var b = {foo: 'bar'}; |
| 18 |
|
| 19 |
printStatus('for-in tests'); |
| 20 |
|
| 21 |
var v; |
| 22 |
section = summary + ': for((v) in b);'; |
| 23 |
expect = 'foo'; |
| 24 |
printStatus(section); |
| 25 |
try |
| 26 |
{ |
| 27 |
eval('for ((v) in b);'); |
| 28 |
actual = v; |
| 29 |
} |
| 30 |
catch(ex) |
| 31 |
{ |
| 32 |
printStatus(ex+''); |
| 33 |
actual = 'error'; |
| 34 |
} |
| 35 |
reportCompare(expect, actual, section); |
| 36 |
|
| 37 |
section = summary + ': function foo(){for((v) in b);};foo();'; |
| 38 |
expect = 'foo'; |
| 39 |
printStatus(section); |
| 40 |
try |
| 41 |
{ |
| 42 |
eval('function foo(){ for ((v) in b);}; foo();'); |
| 43 |
actual = v; |
| 44 |
} |
| 45 |
catch(ex) |
| 46 |
{ |
| 47 |
printStatus(ex+''); |
| 48 |
actual = 'error'; |
| 49 |
} |
| 50 |
reportCompare(expect, actual, section); |
| 51 |
|
| 52 |
section = summary + ': for(a() in b);'; |
| 53 |
expect = 'error'; |
| 54 |
printStatus(section); |
| 55 |
try |
| 56 |
{ |
| 57 |
eval('for (a() in b);'); |
| 58 |
actual = 'no error'; |
| 59 |
} |
| 60 |
catch(ex) |
| 61 |
{ |
| 62 |
printStatus(ex+''); |
| 63 |
actual = 'error'; |
| 64 |
} |
| 65 |
reportCompare(expect, actual, section); |
| 66 |
|
| 67 |
section = summary + ': function foo(){for(a() in b);};foo();'; |
| 68 |
expect = 'error'; |
| 69 |
printStatus(section); |
| 70 |
try |
| 71 |
{ |
| 72 |
eval('function foo(){ for (a() in b);};foo();'); |
| 73 |
actual = 'no error'; |
| 74 |
} |
| 75 |
catch(ex) |
| 76 |
{ |
| 77 |
printStatus(ex+''); |
| 78 |
actual = 'error'; |
| 79 |
} |
| 80 |
reportCompare(expect, actual, section); |
| 81 |
|
| 82 |
section = ': for(new a() in b);'; |
| 83 |
expect = 'error'; |
| 84 |
printStatus(section); |
| 85 |
try |
| 86 |
{ |
| 87 |
eval('for (new a() in b);'); |
| 88 |
actual = 'no error'; |
| 89 |
} |
| 90 |
catch(ex) |
| 91 |
{ |
| 92 |
printStatus(ex+''); |
| 93 |
actual = 'error'; |
| 94 |
} |
| 95 |
reportCompare(expect, actual, summary + section); |
| 96 |
|
| 97 |
section = ': function foo(){for(new a() in b);};foo();'; |
| 98 |
expect = 'error'; |
| 99 |
printStatus(section); |
| 100 |
try |
| 101 |
{ |
| 102 |
eval('function foo(){ for (new a() in b);};foo();'); |
| 103 |
actual = 'no error'; |
| 104 |
} |
| 105 |
catch(ex) |
| 106 |
{ |
| 107 |
printStatus(ex+''); |
| 108 |
actual = 'error'; |
| 109 |
} |
| 110 |
reportCompare(expect, actual, summary + section); |
| 111 |
|
| 112 |
section = ': for(void in b);'; |
| 113 |
expect = 'error'; |
| 114 |
printStatus(section); |
| 115 |
try |
| 116 |
{ |
| 117 |
eval('for (void in b);'); |
| 118 |
actual = 'no error'; |
| 119 |
} |
| 120 |
catch(ex) |
| 121 |
{ |
| 122 |
printStatus(ex+''); |
| 123 |
actual = 'error'; |
| 124 |
} |
| 125 |
reportCompare(expect, actual, summary + section); |
| 126 |
|
| 127 |
section = ': function foo(){for(void in b);};foo();'; |
| 128 |
expect = 'error'; |
| 129 |
printStatus(section); |
| 130 |
try |
| 131 |
{ |
| 132 |
eval('function foo(){ for (void in b);};foo();'); |
| 133 |
actual = 'no error'; |
| 134 |
} |
| 135 |
catch(ex) |
| 136 |
{ |
| 137 |
printStatus(ex+''); |
| 138 |
actual = 'error'; |
| 139 |
} |
| 140 |
reportCompare(expect, actual, summary + section); |
| 141 |
|
| 142 |
var d = 1; |
| 143 |
var e = 2; |
| 144 |
expect = 'error'; |
| 145 |
section = ': for((d*e) in b);'; |
| 146 |
printStatus(section); |
| 147 |
try |
| 148 |
{ |
| 149 |
eval('for ((d*e) in b);'); |
| 150 |
actual = 'no error'; |
| 151 |
} |
| 152 |
catch(ex) |
| 153 |
{ |
| 154 |
printStatus(ex+''); |
| 155 |
actual = 'error'; |
| 156 |
} |
| 157 |
reportCompare(expect, actual, summary + section); |
| 158 |
|
| 159 |
var d = 1; |
| 160 |
var e = 2; |
| 161 |
expect = 'error'; |
| 162 |
section = ': function foo(){for((d*e) in b);};foo();'; |
| 163 |
printStatus(section); |
| 164 |
try |
| 165 |
{ |
| 166 |
eval('function foo(){ for ((d*e) in b);};foo();'); |
| 167 |
actual = 'no error'; |
| 168 |
} |
| 169 |
catch(ex) |
| 170 |
{ |
| 171 |
printStatus(ex+''); |
| 172 |
actual = 'error'; |
| 173 |
} |
| 174 |
reportCompare(expect, actual, summary + section); |
| 175 |
|
| 176 |
const c = 0; |
| 177 |
expect = 'error'; |
| 178 |
section = ': for(c in b);'; |
| 179 |
printStatus(section); |
| 180 |
try |
| 181 |
{ |
| 182 |
eval('for (c in b);'); |
| 183 |
actual = c; |
| 184 |
printStatus('typeof c: ' + (typeof c) + ', c: ' + c); |
| 185 |
} |
| 186 |
catch(ex) |
| 187 |
{ |
| 188 |
printStatus(ex+''); |
| 189 |
actual = 'error'; |
| 190 |
} |
| 191 |
reportCompare(expect, actual, summary + section); |
| 192 |
|
| 193 |
expect = 'error'; |
| 194 |
section = ': function foo(){for(c in b);};foo();'; |
| 195 |
printStatus(section); |
| 196 |
try |
| 197 |
{ |
| 198 |
eval('function foo(){ for (c in b);};foo();'); |
| 199 |
actual = c; |
| 200 |
printStatus('typeof c: ' + (typeof c) + ', c: ' + c); |
| 201 |
} |
| 202 |
catch(ex) |
| 203 |
{ |
| 204 |
printStatus(ex+''); |
| 205 |
actual = 'error'; |
| 206 |
} |
| 207 |
reportCompare(expect, actual, summary + section); |