Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Unified Diff: test/mjsunit/strong/functions.js

Issue 954693003: [strong] Make functions and generators non-extensible non-constructors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/contexts.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strong/functions.js
diff --git a/test/mjsunit/strong/functions.js b/test/mjsunit/strong/functions.js
index 4869ac6dfaef35befff01bac577b6bb57576936e..6956462e5d5edcc45d17a92a83c929dba5eface5 100644
--- a/test/mjsunit/strong/functions.js
+++ b/test/mjsunit/strong/functions.js
@@ -6,28 +6,82 @@
'use strong';
+function f() {}
+function* g() {}
+
(function NoArguments() {
assertThrows("'use strong'; arguments", SyntaxError);
assertThrows("'use strong'; function f() { arguments }", SyntaxError);
+ assertThrows("'use strong'; function* g() { arguments }", SyntaxError);
assertThrows("'use strong'; let f = function() { arguments }", SyntaxError);
+ assertThrows("'use strong'; let g = function*() { arguments }", SyntaxError);
assertThrows("'use strong'; let f = () => arguments", SyntaxError);
// The following are strict mode errors already.
assertThrows("'use strong'; let arguments", SyntaxError);
assertThrows("'use strong'; function f(arguments) {}", SyntaxError);
+ assertThrows("'use strong'; function* g(arguments) {}", SyntaxError);
assertThrows("'use strong'; let f = (arguments) => {}", SyntaxError);
})();
-function g() {}
+(function NoArgumentsProperty() {
+ assertFalse(f.hasOwnProperty("arguments"));
+ assertFalse(g.hasOwnProperty("arguments"));
+ assertThrows(function(){ f.arguments = 0 }, TypeError);
+ assertThrows(function(){ g.arguments = 0 }, TypeError);
+})();
+
+(function NoCaller() {
+ assertFalse(f.hasOwnProperty("caller"));
+ assertFalse(g.hasOwnProperty("caller"));
+ assertThrows(function(){ f.caller = 0 }, TypeError);
+ assertThrows(function(){ g.caller = 0 }, TypeError);
+})();
+
+(function NoCallee() {
+ assertFalse("callee" in f);
+ assertFalse("callee" in g);
+ assertThrows(function(){ f.callee = 0 }, TypeError);
+ assertThrows(function(){ g.callee = 0 }, TypeError);
+})();
-(function LexicalFunctionBindings(global) {
+(function LexicalBindings(global) {
+ assertEquals('function', typeof f);
assertEquals('function', typeof g);
+ assertEquals(undefined, global.f);
assertEquals(undefined, global.g);
})(this);
-(function ImmutableFunctionBindings() {
- function f() {}
- assertThrows(function(){ eval("g = 0") }, TypeError);
- assertThrows(function(){ eval("f = 0") }, TypeError);
- assertEquals('function', typeof g);
+(function ImmutableBindings() {
+ function f2() {}
+ function* g2() {}
+ assertThrows(function(){ f = 0 }, TypeError);
+ assertThrows(function(){ g = 0 }, TypeError);
+ assertThrows(function(){ f2 = 0 }, TypeError);
+ assertThrows(function(){ g2 = 0 }, TypeError);
assertEquals('function', typeof f);
+ assertEquals('function', typeof g);
+ assertEquals('function', typeof f2);
+ assertEquals('function', typeof g2);
+})();
+
+(function NonExtensible() {
+ assertThrows(function(){ f.a = 0 }, TypeError);
+ assertThrows(function(){ g.a = 0 }, TypeError);
+ assertThrows(function(){ Object.defineProperty(f, "a", {value: 0}) }, TypeError);
+ assertThrows(function(){ Object.defineProperty(g, "a", {value: 0}) }, TypeError);
+ assertThrows(function(){ Object.setPrototypeOf(f, {}) }, TypeError);
+ assertThrows(function(){ Object.setPrototypeOf(g, {}) }, TypeError);
+})();
+
+(function NoPrototype() {
+ assertFalse("prototype" in f);
+ assertFalse(g.hasOwnProperty("prototype"));
+ assertThrows(function(){ f.prototype = 0 }, TypeError);
+ assertThrows(function(){ g.prototype = 0 }, TypeError);
+ assertThrows(function(){ f.prototype.a = 0 }, TypeError);
+})();
+
+(function NonConstructor() {
+ assertThrows(function(){ new f }, TypeError);
+ assertThrows(function(){ new g }, TypeError);
})();
« no previous file with comments | « src/contexts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698