Index: test/mjsunit/es6/generators-poisoned-properties.js |
diff --git a/test/mjsunit/es6/generators-poisoned-properties.js b/test/mjsunit/es6/generators-poisoned-properties.js |
index 44d823a50345f09a571cdf79f90fe5dd74d1e0ec..e8610220fc3cec9d7178c00a81a918cec05640e4 100644 |
--- a/test/mjsunit/es6/generators-poisoned-properties.js |
+++ b/test/mjsunit/es6/generators-poisoned-properties.js |
@@ -2,39 +2,41 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-function assertIteratorResult(value, done, result) { |
- assertEquals({value: value, done: done}, result); |
-} |
- |
-function test(f) { |
- var cdesc = Object.getOwnPropertyDescriptor(f, "caller"); |
- var adesc = Object.getOwnPropertyDescriptor(f, "arguments"); |
+(function testRestrictedPropertiesStrict() { |
+ function* generator() { "use strict"; } |
+ assertFalse(generator.hasOwnProperty("arguments")); |
+ assertThrows(function() { return generator.arguments; }, TypeError); |
+ assertThrows(function() { return generator.arguments = {}; }, TypeError); |
- assertFalse(cdesc.enumerable); |
- assertFalse(cdesc.configurable); |
+ assertFalse(generator.hasOwnProperty("caller")); |
+ assertThrows(function() { return generator.caller; }, TypeError); |
+ assertThrows(function() { return generator.caller = {}; }, TypeError); |
+})(); |
- assertFalse(adesc.enumerable); |
- assertFalse(adesc.configurable); |
- assertSame(cdesc.get, cdesc.set); |
- assertSame(cdesc.get, adesc.get); |
- assertSame(cdesc.get, adesc.set); |
+(function testRestrictedPropertiesSloppy() { |
+ function* generator() {} |
+ assertFalse(generator.hasOwnProperty("arguments")); |
+ assertThrows(function() { return generator.arguments; }, TypeError); |
+ assertThrows(function() { return generator.arguments = {}; }, TypeError); |
- assertTrue(cdesc.get instanceof Function); |
- assertEquals(0, cdesc.get.length); |
- assertThrows(cdesc.get, TypeError); |
+ assertFalse(generator.hasOwnProperty("caller")); |
+ assertThrows(function() { return generator.caller; }, TypeError); |
+ assertThrows(function() { return generator.caller = {}; }, TypeError); |
+})(); |
- assertThrows(function() { return f.caller; }, TypeError); |
- assertThrows(function() { f.caller = 42; }, TypeError); |
- assertThrows(function() { return f.arguments; }, TypeError); |
- assertThrows(function() { f.arguments = 42; }, TypeError); |
+function assertIteratorResult(value, done, result) { |
+ assertEquals({value: value, done: done}, result); |
} |
-function *sloppy() { test(sloppy); } |
-function *strict() { "use strict"; test(strict); } |
-test(sloppy); |
-test(strict); |
+(function testIteratorResultStrict() { |
+ function* generator() { "use strict"; } |
+ assertIteratorResult(undefined, true, generator().next()); |
+})(); |
+ |
-assertIteratorResult(undefined, true, sloppy().next()); |
-assertIteratorResult(undefined, true, strict().next()); |
+(function testIteratorResultSloppy() { |
+ function* generator() {} |
+ assertIteratorResult(undefined, true, generator().next()); |
+})(); |