NASHORN-263.js revision 2:da1e581c933b
1285SN/A/*
2461SN/A * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
3285SN/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4285SN/A *
5285SN/A * This code is free software; you can redistribute it and/or modify it
6285SN/A * under the terms of the GNU General Public License version 2 only, as
7285SN/A * published by the Free Software Foundation.
8285SN/A *
9285SN/A * This code is distributed in the hope that it will be useful, but WITHOUT
10285SN/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11285SN/A * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12285SN/A * version 2 for more details (a copy is included in the LICENSE file that
13285SN/A * accompanied this code).
14285SN/A *
15285SN/A * You should have received a copy of the GNU General Public License version
16285SN/A * 2 along with this work; if not, write to the Free Software Foundation,
17285SN/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18285SN/A *
19285SN/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20285SN/A * or visit www.oracle.com if you need additional information or have any
21285SN/A * questions.
22285SN/A */
23285SN/A
24285SN/A/**
25285SN/A * NASHORN-263 : delete of function param or caller scope var should throw SyntaxError in strict mode
26285SN/A *
27285SN/A * @test
28285SN/A * @run
29285SN/A */
30285SN/A
31285SN/Afunction func() {
32285SN/A    "use strict";
33285SN/A    var obj = new Boolean(false);
34285SN/A
35285SN/A    try {
36285SN/A        eval("delete obj;");
37285SN/A        fail("#1 should have thrown SyntaxError");
38285SN/A    } catch (e) {
39285SN/A        if (! (e instanceof SyntaxError)) {
40285SN/A            fail("#2 SyntaxError expected got " + e);
41285SN/A        }
42285SN/A    }
43285SN/A}
44285SN/A
45285SN/Afunc();
46285SN/A
47285SN/Afunction func2(y) {
48285SN/A    'use strict';
49285SN/A    try {
50285SN/A        eval("delete y");
51285SN/A        fail("#3 should have thrown SyntaxError");
52285SN/A    } catch (e) {
53285SN/A        if (! (e instanceof SyntaxError)) {
54285SN/A            fail("#4 SyntaxError expected got " + e);
55285SN/A        }
56285SN/A    }
57285SN/A}
58285SN/A
59285SN/Afunc2(2);
60285SN/A