1b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Copyright 2013 the V8 project authors. All rights reserved.
281362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// Redistribution and use in source and binary forms, with or without
381362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// modification, are permitted provided that the following conditions are
481362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// met:
581362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//
681362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//     * Redistributions of source code must retain the above copyright
781362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//       notice, this list of conditions and the following disclaimer.
881362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//     * Redistributions in binary form must reproduce the above
981362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//       copyright notice, this list of conditions and the following
1081362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//       disclaimer in the documentation and/or other materials provided
1181362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//       with the distribution.
1281362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//     * Neither the name of Google Inc. nor the names of its
1381362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//       contributors may be used to endorse or promote products derived
1481362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//       from this software without specific prior written permission.
1581362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen//
1681362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1781362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1881362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1981362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2081362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2181362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2281362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2381362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2481362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2581362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2681362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2781362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen
28b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Filler long enough to trigger lazy parsing.
29b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochvar filler = "//" + new Array(1024).join('x');
3081362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen
31b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Test that the pre-parser does not crash when the expected contextual
32b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// keyword as part if a 'for' statement is not and identifier.
33b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochtry {
34b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  eval(filler + "\nfunction f() { for (x : y) { } }");
35b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  throw "not reached";
36b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} catch (e) {
37b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  if (!(e instanceof SyntaxError)) throw e;
3881362e16c30e9e970af6b17592f627ad8cdee4d8Kristian Monsen}
39