michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 321874; michael@0: var summary = 'lhs must be a reference in (for lhs in rhs) ...'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: var section; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: function a() {} michael@0: var b = {foo: 'bar'}; michael@0: michael@0: printStatus('for-in tests'); michael@0: michael@0: var v; michael@0: section = summary + ': for((v) in b);'; michael@0: expect = 'foo'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('for ((v) in b);'); michael@0: actual = v; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, section); michael@0: michael@0: section = summary + ': function foo(){for((v) in b);};foo();'; michael@0: expect = 'foo'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('function foo(){ for ((v) in b);}; foo();'); michael@0: actual = v; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, section); michael@0: michael@0: section = summary + ': for(a() in b);'; michael@0: expect = 'error'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('for (a() in b);'); michael@0: actual = 'no error'; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, section); michael@0: michael@0: section = summary + ': function foo(){for(a() in b);};foo();'; michael@0: expect = 'error'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('function foo(){ for (a() in b);};foo();'); michael@0: actual = 'no error'; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, section); michael@0: michael@0: section = ': for(new a() in b);'; michael@0: expect = 'error'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('for (new a() in b);'); michael@0: actual = 'no error'; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, summary + section); michael@0: michael@0: section = ': function foo(){for(new a() in b);};foo();'; michael@0: expect = 'error'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('function foo(){ for (new a() in b);};foo();'); michael@0: actual = 'no error'; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, summary + section); michael@0: michael@0: section = ': for(void in b);'; michael@0: expect = 'error'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('for (void in b);'); michael@0: actual = 'no error'; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, summary + section); michael@0: michael@0: section = ': function foo(){for(void in b);};foo();'; michael@0: expect = 'error'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('function foo(){ for (void in b);};foo();'); michael@0: actual = 'no error'; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, summary + section); michael@0: michael@0: var d = 1; michael@0: var e = 2; michael@0: expect = 'error'; michael@0: section = ': for((d*e) in b);'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('for ((d*e) in b);'); michael@0: actual = 'no error'; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, summary + section); michael@0: michael@0: var d = 1; michael@0: var e = 2; michael@0: expect = 'error'; michael@0: section = ': function foo(){for((d*e) in b);};foo();'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('function foo(){ for ((d*e) in b);};foo();'); michael@0: actual = 'no error'; michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, summary + section); michael@0: michael@0: const c = 0; michael@0: expect = 0; michael@0: section = ': for(c in b);'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('for (c in b);'); michael@0: actual = c; michael@0: printStatus('typeof c: ' + (typeof c) + ', c: ' + c); michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, summary + section); michael@0: michael@0: expect = 0; michael@0: section = ': function foo(){for(c in b);};foo();'; michael@0: printStatus(section); michael@0: try michael@0: { michael@0: eval('function foo(){ for (c in b);};foo();'); michael@0: actual = c; michael@0: printStatus('typeof c: ' + (typeof c) + ', c: ' + c); michael@0: } michael@0: catch(ex) michael@0: { michael@0: printStatus(ex+''); michael@0: actual = 'error'; michael@0: } michael@0: reportCompare(expect, actual, summary + section);