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

Unified Diff: test/mjsunit/harmony/generators-objects.js

Issue 14262004: Generator objects have [[Class]] === "Generator" (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Address review comments Created 7 years, 8 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/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/generators-objects.js
diff --git a/test/mjsunit/harmony/generators-objects.js b/test/mjsunit/harmony/generators-objects.js
index 0c36818c8e04df37be72f46d71d8b8f33e4fb876..de076308cd1dca398b8dfc08ab21de452aea6a6a 100644
--- a/test/mjsunit/harmony/generators-objects.js
+++ b/test/mjsunit/harmony/generators-objects.js
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-generators --harmony-scoping
+// Flags: --harmony-generators --harmony-scoping --allow-natives-syntax
// Test instantations of generators.
@@ -55,6 +55,8 @@ function TestGeneratorObject() {
var iter = g();
assertSame(g.prototype, Object.getPrototypeOf(iter));
assertTrue(iter instanceof g);
+ assertEquals("Generator", %ClassOf(iter));
+ assertEquals("[object Generator]", String(iter));
assertEquals([], Object.getOwnPropertyNames(iter));
assertTrue(iter !== g());
@@ -62,7 +64,34 @@ function TestGeneratorObject() {
iter = new g();
assertSame(g.prototype, Object.getPrototypeOf(iter));
assertTrue(iter instanceof g);
+ assertEquals("Generator", %ClassOf(iter));
+ assertEquals("[object Generator]", String(iter));
assertEquals([], Object.getOwnPropertyNames(iter));
assertTrue(iter !== new g());
}
TestGeneratorObject();
+
+
+// Test the methods of generator objects.
+function TestGeneratorObjectMethods() {
+ function* g() { yield 1; }
+ var iter = g();
+
+ function TestNonGenerator(non_generator) {
+ non_generator.next = iter.next;
+ non_generator.send = iter.send;
+ non_generator.throw = iter.throw;
+ non_generator.close = iter.close;
Michael Starzinger 2013/04/17 14:31:28 I think the four assignments here are obsolete now
+ assertThrows(function() { iter.next.call(non_generator); }, TypeError);
+ assertThrows(function() { iter.send.call(non_generator, 1); }, TypeError);
+ assertThrows(function() { iter.throw.call(non_generator, 1); }, TypeError);
+ assertThrows(function() { iter.close.call(non_generator); }, TypeError);
+ }
+
+ TestNonGenerator(1);
+ TestNonGenerator({});
+ TestNonGenerator(function(){});
+ TestNonGenerator(g);
+ TestNonGenerator(g.prototype);
+}
+TestGeneratorObjectMethods();
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698