test262/test/language/statements/class/definition/methods-gen-yield-as-statement.js
Mike Pennisi 6646d3e94f Re-organize class tests
The `test/language/class/` directory contains a small subset of
Test262's tests for ES2015 classes. The majority of tests for classes
are organized within `test/language/statements/class/`.

- Move the tests that rely on the ClassDeclaration syntactic form from
  `test/language/class/` to `test/language/statements/class/`.
- Move the test that relies on the ClassExpression syntactic form from
  `test/language/class/` to `test/language/expressions/class/`.
2015-07-10 10:36:05 -04:00

48 lines
1.2 KiB
JavaScript

// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
`yield` is a valid statement within generator function bodies.
features: [generators]
es6id: 14.4
---*/
var iter, result;
class A {
*g1() { yield; }
*g2() { yield 1; }
}
iter = A.prototype.g1();
result = iter.next();
assert.sameValue(
result.value, undefined, 'Without right-hand-side: first result `value`'
);
assert.sameValue(
result.done, false, 'Without right-hand-side: first result `done` flag'
);
result = iter.next();
assert.sameValue(
result.value, undefined, 'Without right-hand-side: second result `value`'
);
assert.sameValue(
result.done, true, 'Without right-hand-eside: second result `done` flag'
);
iter = A.prototype.g2();
result = iter.next();
assert.sameValue(
result.value, 1, 'With right-hand-side: first result `value`'
);
assert.sameValue(
result.done, false, 'With right-hand-side: first result `done` flag'
);
result = iter.next();
assert.sameValue(
result.value, undefined, 'With right-hand-side: second result `value`'
);
assert.sameValue(
result.done, true, 'With right-hand-eside: second result `done` flag'
);