parserapi_strict.js revision 1204:9597425b6b38
1231200Smm/*
2231200Smm * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3231200Smm * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4231200Smm *
5231200Smm * This code is free software; you can redistribute it and/or modify it
6231200Smm * under the terms of the GNU General Public License version 2 only, as
7231200Smm * published by the Free Software Foundation.
8231200Smm *
9231200Smm * This code is distributed in the hope that it will be useful, but WITHOUT
10231200Smm * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11231200Smm * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12231200Smm * version 2 for more details (a copy is included in the LICENSE file that
13231200Smm * accompanied this code).
14231200Smm *
15231200Smm * You should have received a copy of the GNU General Public License version
16231200Smm * 2 along with this work; if not, write to the Free Software Foundation,
17231200Smm * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18231200Smm *
19231200Smm * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20231200Smm * or visit www.oracle.com if you need additional information or have any
21231200Smm * questions.
22231200Smm */
23231200Smm
24231200Smm/**
25231200Smm * Nashorn parser API -strict option test.
26231200Smm *
27231200Smm * @test
28231200Smm * @option -scripting
29231200Smm * @run
30231200Smm */
31231200Smm
32231200Smmvar Parser = Java.type("jdk.nashorn.api.tree.Parser");
33231200Smmvar strictParser = Parser.create("-strict");
34231200Smmvar parser = Parser.create();
35231200Smm
36231200Smmvar withStat = <<EOF
37231200Smm
38231200Smmwith({}) {}
39231200SmmEOF;
40231200Smm
41231200SmmstrictParser.parse("with_stat.js", withStat, print);
42231200Smmparser.parse("with_stat1.js", withStat, print);
43231200Smm
44231200Smmvar repeatParam = <<EOF
45231200Smm
46231200Smmfunction func(x, x) {}
47231200SmmEOF;
48231200Smm
49231200SmmstrictParser.parse("repeat_param.js", repeatParam, print);
50231200Smmparser.parse("repeat_param1.js", repeatParam, print);
51231200Smm
52231200Smmvar repeatProp = <<EOF
53231200Smm
54231200Smmvar obj = { foo: 34, foo: 'hello' };
55231200Smm
56231200SmmEOF
57231200Smm
58231200SmmstrictParser.parse("repeat_prop.js", repeatProp, print);
59231200Smmparser.parse("repeat_prop1.js", repeatProp, print);
60231200Smm