PageRenderTime 37ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/webview/native/Source/JavaScriptCore/tests/mozilla/js1_2/statements/continue.js

https://bitbucket.org/rbair/rbair-controls-8
JavaScript | 175 lines | 119 code | 22 blank | 34 comment | 28 complexity | e1c962fab6bec04a40270d1124ecd57f MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0, LGPL-2.0
  1. /* The contents of this file are subject to the Netscape Public
  2. * License Version 1.1 (the "License"); you may not use this file
  3. * except in compliance with the License. You may obtain a copy of
  4. * the License at http://www.mozilla.org/NPL/
  5. *
  6. * Software distributed under the License is distributed on an "AS
  7. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  8. * implied. See the License for the specific language governing
  9. * rights and limitations under the License.
  10. *
  11. * The Original Code is Mozilla Communicator client code, released March
  12. * 31, 1998.
  13. *
  14. * The Initial Developer of the Original Code is Netscape Communications
  15. * Corporation. Portions created by Netscape are
  16. * Copyright (C) 1998 Netscape Communications Corporation. All
  17. * Rights Reserved.
  18. *
  19. * Contributor(s):
  20. *
  21. */
  22. /**
  23. Filename: continue.js
  24. Description: 'Tests the continue statement'
  25. Author: Nick Lerissa
  26. Date: March 18, 1998
  27. */
  28. var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
  29. var VERSION = 'no version';
  30. startTest();
  31. var TITLE = 'statements: continue';
  32. writeHeaderToLog("Executing script: continue.js");
  33. writeHeaderToLog( SECTION + " "+ TITLE);
  34. var count = 0;
  35. var testcases = new Array();
  36. var i,j;
  37. j = 0;
  38. for (i = 0; i < 200; i++)
  39. {
  40. if (i == 100)
  41. continue;
  42. j++;
  43. }
  44. // '"continue" in a "for" loop'
  45. testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop',
  46. 199, j);
  47. j = 0;
  48. out1:
  49. for (i = 0; i < 1000; i++)
  50. {
  51. if (i == 100)
  52. {
  53. out2:
  54. for (var k = 0; k < 1000; k++)
  55. {
  56. if (k == 500) continue out1;
  57. }
  58. j = 3000;
  59. }
  60. j++;
  61. }
  62. // '"continue" in a "for" loop with a "label"'
  63. testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop with a "label"',
  64. 999, j);
  65. i = 0;
  66. j = 1;
  67. while (i != j)
  68. {
  69. i++;
  70. if (i == 100) continue;
  71. j++;
  72. }
  73. // '"continue" in a "while" loop'
  74. testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop',
  75. 100, j );
  76. j = 0;
  77. i = 0;
  78. out3:
  79. while (i < 1000)
  80. {
  81. if (i == 100)
  82. {
  83. var k = 0;
  84. out4:
  85. while (k < 1000)
  86. {
  87. if (k == 500)
  88. {
  89. i++;
  90. continue out3;
  91. }
  92. k++;
  93. }
  94. j = 3000;
  95. }
  96. j++;
  97. i++;
  98. }
  99. // '"continue" in a "while" loop with a "label"'
  100. testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop with a "label"',
  101. 999, j);
  102. i = 0;
  103. j = 1;
  104. do
  105. {
  106. i++;
  107. if (i == 100) continue;
  108. j++;
  109. } while (i != j);
  110. // '"continue" in a "do" loop'
  111. testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop',
  112. 100, j );
  113. j = 0;
  114. i = 0;
  115. out5:
  116. do
  117. {
  118. if (i == 100)
  119. {
  120. var k = 0;
  121. out6:
  122. do
  123. {
  124. if (k == 500)
  125. {
  126. i++;
  127. continue out5;
  128. }
  129. k++;
  130. }while (k < 1000);
  131. j = 3000;
  132. }
  133. j++;
  134. i++;
  135. }while (i < 1000);
  136. // '"continue" in a "do" loop with a "label"'
  137. testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop with a "label"',
  138. 999, j);
  139. function test()
  140. {
  141. for ( tc=0; tc < testcases.length; tc++ ) {
  142. testcases[tc].passed = writeTestCaseResult(
  143. testcases[tc].expect,
  144. testcases[tc].actual,
  145. testcases[tc].description +" = "+
  146. testcases[tc].actual );
  147. testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
  148. }
  149. stopTest();
  150. return ( testcases );
  151. }
  152. test();