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(); |