1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Flags: --strong-mode
12 (function NoArguments() {
13 assertThrows("'use strong'; arguments", SyntaxError);
14 assertThrows("'use strong'; function f() { arguments }", SyntaxError);
15 assertThrows("'use strong'; function* g() { arguments }", SyntaxError);
16 assertThrows("'use strong'; let f = function() { arguments }", SyntaxError);
17 assertThrows("'use strong'; let g = function*() { arguments }", SyntaxError);
18 assertThrows("'use strong'; let f = () => arguments", SyntaxError);
19 // The following are strict mode errors already.
20 assertThrows("'use strong'; let arguments", SyntaxError);
21 assertThrows("'use strong'; function f(arguments) {}", SyntaxError);
22 assertThrows("'use strong'; function* g(arguments) {}", SyntaxError);
23 assertThrows("'use strong'; let f = (arguments) => {}", SyntaxError);
26 (function NoArgumentsProperty() {
27 assertFalse(f.hasOwnProperty("arguments"));
28 assertFalse(g.hasOwnProperty("arguments"));
29 assertThrows(function(){ f.arguments = 0 }, TypeError);
30 assertThrows(function(){ g.arguments = 0 }, TypeError);
33 (function NoCaller() {
34 assertFalse(f.hasOwnProperty("caller"));
35 assertFalse(g.hasOwnProperty("caller"));
36 assertThrows(function(){ f.caller = 0 }, TypeError);
37 assertThrows(function(){ g.caller = 0 }, TypeError);
40 (function NoCallee() {
41 assertFalse("callee" in f);
42 assertFalse("callee" in g);
43 assertThrows(function(){ f.callee = 0 }, TypeError);
44 assertThrows(function(){ g.callee = 0 }, TypeError);
47 (function LexicalBindings(global) {
48 assertEquals('function', typeof f);
49 assertEquals('function', typeof g);
50 assertEquals(undefined, global.f);
51 assertEquals(undefined, global.g);
54 (function ImmutableBindings() {
57 assertThrows(function(){ f = 0 }, TypeError);
58 assertThrows(function(){ g = 0 }, TypeError);
59 assertThrows(function(){ f2 = 0 }, TypeError);
60 assertThrows(function(){ g2 = 0 }, TypeError);
61 assertEquals('function', typeof f);
62 assertEquals('function', typeof g);
63 assertEquals('function', typeof f2);
64 assertEquals('function', typeof g2);
67 (function NonExtensible() {
68 assertThrows(function(){ f.a = 0 }, TypeError);
69 assertThrows(function(){ g.a = 0 }, TypeError);
70 assertThrows(function(){ Object.defineProperty(f, "a", {value: 0}) }, TypeError);
71 assertThrows(function(){ Object.defineProperty(g, "a", {value: 0}) }, TypeError);
72 assertThrows(function(){ Object.setPrototypeOf(f, {}) }, TypeError);
73 assertThrows(function(){ Object.setPrototypeOf(g, {}) }, TypeError);
76 (function NoPrototype() {
77 assertFalse("prototype" in f);
78 assertFalse(g.hasOwnProperty("prototype"));
79 assertThrows(function(){ f.prototype = 0 }, TypeError);
80 assertThrows(function(){ g.prototype = 0 }, TypeError);
81 assertThrows(function(){ f.prototype.a = 0 }, TypeError);
84 (function NonConstructor() {
85 assertThrows(function(){ new f }, TypeError);
86 assertThrows(function(){ new g }, TypeError);