PageRenderTime 48ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/tests/js1_2/statements/continue.js

https://bitbucket.org/soko/mozilla-central
JavaScript | 176 lines | 104 code | 22 blank | 50 comment | 27 complexity | 4116ac2d86165ac12366fb520a67d1a6 MD5 | raw file
Possible License(s): GPL-2.0, JSON, 0BSD, LGPL-3.0, AGPL-1.0, MIT, MPL-2.0-no-copyleft-exception, BSD-3-Clause, LGPL-2.1, Apache-2.0
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is Mozilla Communicator client code, released
  16. * March 31, 1998.
  17. *
  18. * The Initial Developer of the Original Code is
  19. * Netscape Communications Corporation.
  20. * Portions created by the Initial Developer are Copyright (C) 1998
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. /**
  39. Filename: continue.js
  40. Description: 'Tests the continue statement'
  41. Author: Nick Lerissa
  42. Date: March 18, 1998
  43. */
  44. var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
  45. var VERSION = 'no version';
  46. startTest();
  47. var TITLE = 'statements: continue';
  48. writeHeaderToLog("Executing script: continue.js");
  49. writeHeaderToLog( SECTION + " "+ TITLE);
  50. var i,j;
  51. j = 0;
  52. for (i = 0; i < 200; i++)
  53. {
  54. if (i == 100)
  55. continue;
  56. j++;
  57. }
  58. // '"continue" in a "for" loop'
  59. new TestCase ( SECTION, '"continue" in "for" loop',
  60. 199, j);
  61. j = 0;
  62. out1:
  63. for (i = 0; i < 1000; i++)
  64. {
  65. if (i == 100)
  66. {
  67. out2:
  68. for (var k = 0; k < 1000; k++)
  69. {
  70. if (k == 500) continue out1;
  71. }
  72. j = 3000;
  73. }
  74. j++;
  75. }
  76. // '"continue" in a "for" loop with a "label"'
  77. new TestCase ( SECTION, '"continue" in "for" loop with a "label"',
  78. 999, j);
  79. i = 0;
  80. j = 1;
  81. while (i != j)
  82. {
  83. i++;
  84. if (i == 100) continue;
  85. j++;
  86. }
  87. // '"continue" in a "while" loop'
  88. new TestCase ( SECTION, '"continue" in a "while" loop',
  89. 100, j );
  90. j = 0;
  91. i = 0;
  92. out3:
  93. while (i < 1000)
  94. {
  95. if (i == 100)
  96. {
  97. var k = 0;
  98. out4:
  99. while (k < 1000)
  100. {
  101. if (k == 500)
  102. {
  103. i++;
  104. continue out3;
  105. }
  106. k++;
  107. }
  108. j = 3000;
  109. }
  110. j++;
  111. i++;
  112. }
  113. // '"continue" in a "while" loop with a "label"'
  114. new TestCase ( SECTION, '"continue" in a "while" loop with a "label"',
  115. 999, j);
  116. i = 0;
  117. j = 1;
  118. do
  119. {
  120. i++;
  121. if (i == 100) continue;
  122. j++;
  123. } while (i != j);
  124. // '"continue" in a "do" loop'
  125. new TestCase ( SECTION, '"continue" in a "do" loop',
  126. 100, j );
  127. j = 0;
  128. i = 0;
  129. out5:
  130. do
  131. {
  132. if (i == 100)
  133. {
  134. var k = 0;
  135. out6:
  136. do
  137. {
  138. if (k == 500)
  139. {
  140. i++;
  141. continue out5;
  142. }
  143. k++;
  144. }while (k < 1000);
  145. j = 3000;
  146. }
  147. j++;
  148. i++;
  149. }while (i < 1000);
  150. // '"continue" in a "do" loop with a "label"'
  151. new TestCase ( SECTION, '"continue" in a "do" loop with a "label"',
  152. 999, j);
  153. test();