js/src/tests/ecma_2/Statements/while-004.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 * File Name: while-004
michael@0 9 * ECMA Section:
michael@0 10 * Description: while statement
michael@0 11 *
michael@0 12 * Author: christine@netscape.com
michael@0 13 * Date: 11 August 1998
michael@0 14 */
michael@0 15 var SECTION = "while-004";
michael@0 16 var VERSION = "ECMA_2";
michael@0 17 var TITLE = "while statement";
michael@0 18 var BUGNUMBER="316725";
michael@0 19
michael@0 20 startTest();
michael@0 21 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 22
michael@0 23 DoWhile_1();
michael@0 24 DoWhile_2();
michael@0 25 DoWhile_3();
michael@0 26 DoWhile_4();
michael@0 27 DoWhile_5();
michael@0 28
michael@0 29 test();
michael@0 30
michael@0 31 /**
michael@0 32 * Break out of a while by calling return.
michael@0 33 *
michael@0 34 * Tests: 12.6.2 step 6.
michael@0 35 */
michael@0 36 function dowhile() {
michael@0 37 result = "pass";
michael@0 38
michael@0 39 while (true) {
michael@0 40 return result;
michael@0 41 result = "fail: hit code after return statement";
michael@0 42 break;
michael@0 43 }
michael@0 44 }
michael@0 45
michael@0 46 function DoWhile_1() {
michael@0 47 description = "return statement in a while block";
michael@0 48
michael@0 49 result = dowhile();
michael@0 50
michael@0 51 new TestCase(
michael@0 52 SECTION,
michael@0 53 "DoWhile_1" + description,
michael@0 54 "pass",
michael@0 55 result );
michael@0 56 }
michael@0 57
michael@0 58 /**
michael@0 59 * While with a labeled continue statement. Verify that statements
michael@0 60 * after the continue statement are not evaluated.
michael@0 61 *
michael@0 62 * Tests: 12.6.2 step 8.
michael@0 63 *
michael@0 64 */
michael@0 65 function DoWhile_2() {
michael@0 66 var description = "while with a labeled continue statement";
michael@0 67 var result1 = "pass";
michael@0 68 var result2 = "fail: did not execute code after loop, but inside label";
michael@0 69 var i = 0;
michael@0 70 var j = 0;
michael@0 71
michael@0 72 theloop:
michael@0 73 while( i++ < 10 ) {
michael@0 74 j++;
michael@0 75 continue theloop;
michael@0 76 result1 = "failed: hit code after continue statement";
michael@0 77 }
michael@0 78 result2 = "pass";
michael@0 79
michael@0 80 new TestCase(
michael@0 81 SECTION,
michael@0 82 "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")",
michael@0 83 true,
michael@0 84 j == 10 );
michael@0 85
michael@0 86 new TestCase(
michael@0 87 SECTION,
michael@0 88 "DoWhile_2: " +description +" - code after labeled continue should not be executed",
michael@0 89 "pass",
michael@0 90 result1 );
michael@0 91
michael@0 92 new TestCase(
michael@0 93 SECTION,
michael@0 94 "DoWhile_2: " +description +" - code after loop but inside label should be executed",
michael@0 95 "pass",
michael@0 96 result2 );
michael@0 97 }
michael@0 98
michael@0 99 /**
michael@0 100 * While with a labeled break.
michael@0 101 *
michael@0 102 */
michael@0 103 function DoWhile_3() {
michael@0 104 var description = "while with a labeled break statement";
michael@0 105 var result1 = "pass";
michael@0 106 var result2 = "pass";
michael@0 107 var result3 = "fail: did not get to code after label";
michael@0 108
michael@0 109 woohoo: {
michael@0 110 while( true ) {
michael@0 111 break woohoo;
michael@0 112 result1 = "fail: got to code after a break";
michael@0 113 }
michael@0 114 result2 = "fail: got to code outside of loop but inside label";
michael@0 115 }
michael@0 116
michael@0 117 result3 = "pass";
michael@0 118
michael@0 119 new TestCase(
michael@0 120 SECTION,
michael@0 121 "DoWhile_3: " +description +" - verify break out of loop",
michael@0 122 "pass",
michael@0 123 result1 );
michael@0 124
michael@0 125
michael@0 126 new TestCase(
michael@0 127 SECTION,
michael@0 128 "DoWhile_3: " +description +" - verify break out of label",
michael@0 129 "pass",
michael@0 130 result2 );
michael@0 131
michael@0 132 new TestCase(
michael@0 133 SECTION,
michael@0 134 "DoWhile_3: " +description + " - verify correct exit from label",
michael@0 135 "pass",
michael@0 136 result3 );
michael@0 137 }
michael@0 138
michael@0 139
michael@0 140 /**
michael@0 141 * Labled while with an unlabeled break
michael@0 142 *
michael@0 143 */
michael@0 144 function DoWhile_4() {
michael@0 145 var description = "labeled while with an unlabeled break";
michael@0 146 var result1 = "pass";
michael@0 147 var result2 = "pass";
michael@0 148 var result3 = "fail: did not evaluate statement after label";
michael@0 149
michael@0 150 woohooboy: {
michael@0 151 while( true ) {
michael@0 152 break woohooboy;
michael@0 153 result1 = "fail: got to code after the break";
michael@0 154 }
michael@0 155 result2 = "fail: broke out of while, but not out of label";
michael@0 156 }
michael@0 157 result3 = "pass";
michael@0 158
michael@0 159 new TestCase(
michael@0 160 SECTION,
michael@0 161 "DoWhile_4: " +description +" - verify break out of while loop",
michael@0 162 "pass",
michael@0 163 result1 );
michael@0 164
michael@0 165 new TestCase(
michael@0 166 SECTION,
michael@0 167 "DoWhile_4: " +description + " - verify break out of label",
michael@0 168 "pass",
michael@0 169 result2 );
michael@0 170
michael@0 171 new TestCase(
michael@0 172 SECTION,
michael@0 173 "DoWhile_4: " +description +" - verify that statements after label are evaluated",
michael@0 174 "pass",
michael@0 175 result3 );
michael@0 176 }
michael@0 177
michael@0 178 /**
michael@0 179 * in this case, should behave the same way as
michael@0 180 *
michael@0 181 *
michael@0 182 */
michael@0 183 function DoWhile_5() {
michael@0 184 var description = "while with a labeled continue statement";
michael@0 185 var result1 = "pass";
michael@0 186 var result2 = "fail: did not execute code after loop, but inside label";
michael@0 187 var i = 0;
michael@0 188 var j = 0;
michael@0 189
michael@0 190 theloop: {
michael@0 191 j++;
michael@0 192 while( i++ < 10 ) {
michael@0 193 continue;
michael@0 194 result1 = "failed: hit code after continue statement";
michael@0 195 }
michael@0 196 result2 = "pass";
michael@0 197 }
michael@0 198
michael@0 199 new TestCase(
michael@0 200 SECTION,
michael@0 201 "DoWhile_5: " +description + " - continue should not execute statements above the loop",
michael@0 202 true,
michael@0 203 ( j == 1 ) );
michael@0 204
michael@0 205 new TestCase(
michael@0 206 SECTION,
michael@0 207 "DoWhile_5: " +description +" - code after labeled continue should not be executed",
michael@0 208 "pass",
michael@0 209 result1 );
michael@0 210
michael@0 211 new TestCase(
michael@0 212 SECTION,
michael@0 213 "DoWhile_5: " +description +" - code after loop but inside label should be executed",
michael@0 214 "pass",
michael@0 215 result2 );
michael@0 216 }
michael@0 217

mercurial