generators-deferred.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // Smoke test to verify that generator functions successfully execute when
  6. // they are deferred parsed and deferred deserialized.
  7. var passed = true;
  8. function validateValue(ir, ev) {
  9. if (ir.value !== ev) {
  10. WScript.Echo("FAILED: Expected '" + ev + "' but got '" + ir.value + "'");
  11. passed = false;
  12. }
  13. }
  14. function test() {
  15. function* gf() {
  16. yield 1;
  17. yield 2;
  18. yield 3;
  19. return null;
  20. }
  21. var g = gf();
  22. validateValue(g.next(), 1);
  23. validateValue(g.next(), 2);
  24. validateValue(g.next(), 3);
  25. validateValue(g.next(), null);
  26. }
  27. test();
  28. if (passed) {
  29. WScript.Echo("PASSED");
  30. }