PageRenderTime 232ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/rbair/rbair-controls-8
JavaScript | 162 lines | 104 code | 24 blank | 34 comment | 26 complexity | 9e765d45996b88290e80697382d52c22 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: break.js
  24. Description: 'Tests the break 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: break';
  32. writeHeaderToLog("Executing script: break.js");
  33. writeHeaderToLog( SECTION + " "+ TITLE);
  34. var count = 0;
  35. var testcases = new Array();
  36. var i,j;
  37. for (i = 0; i < 1000; i++)
  38. {
  39. if (i == 100) break;
  40. }
  41. // 'breaking out of "for" loop'
  42. testcases[count++] = new TestCase ( SECTION, 'breaking out of "for" loop',
  43. 100, i);
  44. j = 2000;
  45. out1:
  46. for (i = 0; i < 1000; i++)
  47. {
  48. if (i == 100)
  49. {
  50. out2:
  51. for (j = 0; j < 1000; j++)
  52. {
  53. if (j == 500) break out1;
  54. }
  55. j = 2001;
  56. }
  57. j = 2002;
  58. }
  59. // 'breaking out of a "for" loop with a "label"'
  60. testcases[count++] = new TestCase ( SECTION, 'breaking out of a "for" loop with a "label"',
  61. 500, j);
  62. i = 0;
  63. while (i < 1000)
  64. {
  65. if (i == 100) break;
  66. i++;
  67. }
  68. // 'breaking out of a "while" loop'
  69. testcases[count++] = new TestCase ( SECTION, 'breaking out of a "while" loop',
  70. 100, i );
  71. j = 2000;
  72. i = 0;
  73. out3:
  74. while (i < 1000)
  75. {
  76. if (i == 100)
  77. {
  78. j = 0;
  79. out4:
  80. while (j < 1000)
  81. {
  82. if (j == 500) break out3;
  83. j++;
  84. }
  85. j = 2001;
  86. }
  87. j = 2002;
  88. i++;
  89. }
  90. // 'breaking out of a "while" loop with a "label"'
  91. testcases[count++] = new TestCase ( SECTION, 'breaking out of a "while" loop with a "label"',
  92. 500, j);
  93. i = 0;
  94. do
  95. {
  96. if (i == 100) break;
  97. i++;
  98. } while (i < 1000);
  99. // 'breaking out of a "do" loop'
  100. testcases[count++] = new TestCase ( SECTION, 'breaking out of a "do" loop',
  101. 100, i );
  102. j = 2000;
  103. i = 0;
  104. out5:
  105. do
  106. {
  107. if (i == 100)
  108. {
  109. j = 0;
  110. out6:
  111. do
  112. {
  113. if (j == 500) break out5;
  114. j++;
  115. }while (j < 1000);
  116. j = 2001;
  117. }
  118. j = 2002;
  119. i++;
  120. }while (i < 1000);
  121. // 'breaking out of a "do" loop with a "label"'
  122. testcases[count++] = new TestCase ( SECTION, 'breaking out of a "do" loop with a "label"',
  123. 500, j);
  124. function test()
  125. {
  126. for ( tc=0; tc < testcases.length; tc++ ) {
  127. testcases[tc].passed = writeTestCaseResult(
  128. testcases[tc].expect,
  129. testcases[tc].actual,
  130. testcases[tc].description +" = "+
  131. testcases[tc].actual );
  132. testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
  133. }
  134. stopTest();
  135. return ( testcases );
  136. }
  137. test();