JDK-8006570.js revision 41:935dcec38e9a
1145554Sdarrenr/*
2145554Sdarrenr * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3145554Sdarrenr * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4255332Scy *
5145554Sdarrenr * This code is free software; you can redistribute it and/or modify it
6145554Sdarrenr * under the terms of the GNU General Public License version 2 only, as
7255332Scy * published by the Free Software Foundation.
8255332Scy *
9145554Sdarrenr * This code is distributed in the hope that it will be useful, but WITHOUT
10145554Sdarrenr * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11145554Sdarrenr * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12255332Scy * version 2 for more details (a copy is included in the LICENSE file that
13145554Sdarrenr * accompanied this code).
14145554Sdarrenr *
15255332Scy * You should have received a copy of the GNU General Public License version
16145554Sdarrenr * 2 along with this work; if not, write to the Free Software Foundation,
17255332Scy * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18145554Sdarrenr *
19255332Scy * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20145554Sdarrenr * or visit www.oracle.com if you need additional information or have any
21145554Sdarrenr * questions.
22145554Sdarrenr */
23145554Sdarrenr
24255332Scy/**
25255332Scy * JDK-8006570 : this-value for non-strict functions should be converted to object
26255332Scy *
27145554Sdarrenr * @test
28145554Sdarrenr * @run
29145554Sdarrenr */
30145554Sdarrenr
31145554Sdarrenrvar strict, nonstrict;
32145554Sdarrenr
33145554Sdarrenrnonstrict = Object.prototype.nonstrict = function nonstrict() {
34145554Sdarrenr    print(typeof this, this instanceof Object);
35145554Sdarrenr};
36145554Sdarrenr
37145554Sdarrenr(function() {
38145554Sdarrenr    "use strict";
39145554Sdarrenr    strict = Object.prototype.strict = function strict() {
40145554Sdarrenr        print(typeof this, this instanceof Object);
41145554Sdarrenr    };
42145554Sdarrenr})();
43145554Sdarrenr
44145554Sdarrenr"foo".nonstrict();
45145554Sdarrenr(1).nonstrict();
46145554Sdarrenrtrue.nonstrict();
47145554Sdarrenrnonstrict();
48255332Scynonstrict.call(null);
49255332Scynonstrict.call("foo");
50255332Scynonstrict.call(1);
51145554Sdarrenrnonstrict.call(true);
52145554Sdarrenr
53145554Sdarrenr"foo".strict();
54145554Sdarrenr(1).strict();
55145554Sdarrenrtrue.strict();
56255332Scystrict();
57255332Scystrict.call(null);
58255332Scystrict.call("foo");
59145554Sdarrenrstrict.call(1);
60145554Sdarrenrstrict.call(true);