DoWhile.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. // Use do..while as a statement inside if..else
  6. var str="if (1) do WScript.Echo(1); while (false); else 1;";
  7. try
  8. {
  9. eval(str);
  10. }
  11. catch (e)
  12. {
  13. WScript.Echo(e);
  14. }
  15. // Use do..while as a statement inside another do..while
  16. str="do do WScript.Echo(2); while (false); while(false);"
  17. try
  18. {
  19. eval(str);
  20. }
  21. catch (e)
  22. {
  23. WScript.Echo(e);
  24. }
  25. // do..while without a semicolon at the end, followed by another statement
  26. // do while surrounds a statement without a semicolon, but ended with a newline
  27. var a = 10;
  28. do
  29. WScript.Echo(3)
  30. while (false)
  31. var b=20;
  32. with(a) do WScript.Echo(4); while (false)
  33. for(var i=0; i<5; i++)
  34. do
  35. WScript.Echo("5."+i);
  36. while(false)
  37. // do..while as the last statement ended by EOF
  38. do
  39. WScript.Echo(6)
  40. while (false)