2014-05-19 10:47:00 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2016-06-08 11:58:03 +00:00
|
|
|
// Flags: --ignition-generators
|
|
|
|
|
2015-04-09 22:40:16 +00:00
|
|
|
(function testRestrictedPropertiesStrict() {
|
|
|
|
function* generator() { "use strict"; }
|
|
|
|
assertFalse(generator.hasOwnProperty("arguments"));
|
|
|
|
assertThrows(function() { return generator.arguments; }, TypeError);
|
|
|
|
assertThrows(function() { return generator.arguments = {}; }, TypeError);
|
2014-05-19 10:47:00 +00:00
|
|
|
|
2015-04-09 22:40:16 +00:00
|
|
|
assertFalse(generator.hasOwnProperty("caller"));
|
|
|
|
assertThrows(function() { return generator.caller; }, TypeError);
|
|
|
|
assertThrows(function() { return generator.caller = {}; }, TypeError);
|
|
|
|
})();
|
2014-05-19 10:47:00 +00:00
|
|
|
|
|
|
|
|
2015-04-09 22:40:16 +00:00
|
|
|
(function testRestrictedPropertiesSloppy() {
|
|
|
|
function* generator() {}
|
|
|
|
assertFalse(generator.hasOwnProperty("arguments"));
|
|
|
|
assertThrows(function() { return generator.arguments; }, TypeError);
|
|
|
|
assertThrows(function() { return generator.arguments = {}; }, TypeError);
|
2014-05-19 10:47:00 +00:00
|
|
|
|
2015-04-09 22:40:16 +00:00
|
|
|
assertFalse(generator.hasOwnProperty("caller"));
|
|
|
|
assertThrows(function() { return generator.caller; }, TypeError);
|
|
|
|
assertThrows(function() { return generator.caller = {}; }, TypeError);
|
|
|
|
})();
|
2014-05-19 10:47:00 +00:00
|
|
|
|
2015-04-09 22:40:16 +00:00
|
|
|
function assertIteratorResult(value, done, result) {
|
|
|
|
assertEquals({value: value, done: done}, result);
|
2014-05-19 10:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-09 22:40:16 +00:00
|
|
|
(function testIteratorResultStrict() {
|
|
|
|
function* generator() { "use strict"; }
|
|
|
|
assertIteratorResult(undefined, true, generator().next());
|
|
|
|
})();
|
|
|
|
|
2014-05-19 10:47:00 +00:00
|
|
|
|
2015-04-09 22:40:16 +00:00
|
|
|
(function testIteratorResultSloppy() {
|
|
|
|
function* generator() {}
|
|
|
|
assertIteratorResult(undefined, true, generator().next());
|
|
|
|
})();
|