Chromium Code Reviews| 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..2f652b60ac9e795c8cf05a58eca45ac39893490d 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,7 @@ function TestGeneratorObject() { |
| var iter = g(); |
| assertSame(g.prototype, Object.getPrototypeOf(iter)); |
| assertTrue(iter instanceof g); |
| + assertEquals("Generator", %ClassOf(iter)); |
|
Michael Starzinger
2013/04/17 12:52:19
Could we also add a check for the ToString represe
wingo
2013/04/17 14:23:51
Done.
|
| assertEquals([], Object.getOwnPropertyNames(iter)); |
| assertTrue(iter !== g()); |
| @@ -62,7 +63,33 @@ function TestGeneratorObject() { |
| iter = new g(); |
| assertSame(g.prototype, Object.getPrototypeOf(iter)); |
| assertTrue(iter instanceof g); |
| + assertEquals("Generator", %ClassOf(iter)); |
|
Michael Starzinger
2013/04/17 12:52:19
Likewise.
wingo
2013/04/17 14:23:51
Done.
|
| 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; |
|
Michael Starzinger
2013/04/17 12:52:19
For primitive values (i.e. the "1" value) this ass
wingo
2013/04/17 14:23:51
Done.
|
| + non_generator.send = iter.send; |
| + non_generator.throw = iter.throw; |
| + non_generator.close = iter.close; |
| + assertThrows(function() { return non_generator.next(); }, TypeError); |
| + assertThrows(function() { return non_generator.send(1); }, TypeError); |
| + assertThrows(function() { return non_generator.throw(1); }, TypeError); |
| + assertThrows(function() { return non_generator.close(); }, TypeError); |
| + } |
| + |
| + TestNonGenerator(1); |
| + TestNonGenerator({}); |
| + TestNonGenerator(function(){}); |
| + TestNonGenerator(g); |
| + TestNonGenerator(g.prototype); |
| +} |
| +TestGeneratorObjectMethods(); |