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 File Name: 7.6.js 24 ECMA Section: Punctuators 25 Description: 26 27 This tests verifies that all ECMA punctutors are recognized as a 28 token separator, but does not attempt to verify the functionality 29 of any punctuator. 30 31 Author: christine@netscape.com 32 Date: 12 november 1997 33*/ 34 35 var SECTION = "7.6"; 36 var VERSION = "ECMA_1"; 37 startTest(); 38 var TITLE = "Punctuators"; 39 40 writeHeaderToLog( SECTION + " "+ TITLE); 41 42 var testcases = new Array(); 43 44 // == 45 testcases[tc++] = new TestCase( SECTION, 46 "var c,d;c==d", 47 true, 48 eval("var c,d;c==d") ); 49 50 // = 51 52 testcases[tc++] = new TestCase( SECTION, 53 "var a=true;a", 54 true, 55 eval("var a=true;a") ); 56 57 // > 58 testcases[tc++] = new TestCase( SECTION, 59 "var a=true,b=false;a>b", 60 true, 61 eval("var a=true,b=false;a>b") ); 62 63 // < 64 testcases[tc++] = new TestCase( SECTION, 65 "var a=true,b=false;a<b", 66 false, 67 eval("var a=true,b=false;a<b") ); 68 69 // <= 70 testcases[tc++] = new TestCase( SECTION, 71 "var a=0xFFFF,b=0X0FFF;a<=b", 72 false, 73 eval("var a=0xFFFF,b=0X0FFF;a<=b") ); 74 75 // >= 76 testcases[tc++] = new TestCase( SECTION, 77 "var a=0xFFFF,b=0XFFFE;a>=b", 78 true, 79 eval("var a=0xFFFF,b=0XFFFE;a>=b") ); 80 81 // != 82 testcases[tc++] = new TestCase( SECTION, 83 "var a=true,b=false;a!=b", 84 true, 85 eval("var a=true,b=false;a!=b") ); 86 87 testcases[tc++] = new TestCase( SECTION, 88 "var a=false,b=false;a!=b", 89 false, 90 eval("var a=false,b=false;a!=b") ); 91 // , 92 testcases[tc++] = new TestCase( SECTION, 93 "var a=true,b=false;a,b", 94 false, 95 eval("var a=true,b=false;a,b") ); 96 // ! 97 testcases[tc++] = new TestCase( SECTION, 98 "var a=true,b=false;!a", 99 false, 100 eval("var a=true,b=false;!a") ); 101 102 // ~ 103 testcases[tc++] = new TestCase( SECTION, 104 "var a=true;~a", 105 -2, 106 eval("var a=true;~a") ); 107 // ? 108 testcases[tc++] = new TestCase( SECTION, 109 "var a=true; (a ? 'PASS' : '')", 110 "PASS", 111 eval("var a=true; (a ? 'PASS' : '')") ); 112 113 // : 114 115 testcases[tc++] = new TestCase( SECTION, 116 "var a=false; (a ? 'FAIL' : 'PASS')", 117 "PASS", 118 eval("var a=false; (a ? 'FAIL' : 'PASS')") ); 119 // . 120 121 testcases[tc++] = new TestCase( SECTION, 122 "var a=Number;a.NaN", 123 NaN, 124 eval("var a=Number;a.NaN") ); 125 126 // && 127 testcases[tc++] = new TestCase( SECTION, 128 "var a=true,b=true;if(a&&b)'PASS';else'FAIL'", 129 "PASS", 130 eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") ); 131 132 // || 133 testcases[tc++] = new TestCase( SECTION, 134 "var a=false,b=false;if(a||b)'FAIL';else'PASS'", 135 "PASS", 136 eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") ); 137 // ++ 138 testcases[tc++] = new TestCase( SECTION, 139 "var a=false,b=false;++a", 140 1, 141 eval("var a=false,b=false;++a") ); 142 // -- 143 testcases[tc++] = new TestCase( SECTION, 144 "var a=true,b=false--a", 145 0, 146 eval("var a=true,b=false;--a") ); 147 // + 148 149 testcases[tc++] = new TestCase( SECTION, 150 "var a=true,b=true;a+b", 151 2, 152 eval("var a=true,b=true;a+b") ); 153 // - 154 testcases[tc++] = new TestCase( SECTION, 155 "var a=true,b=true;a-b", 156 0, 157 eval("var a=true,b=true;a-b") ); 158 // * 159 testcases[tc++] = new TestCase( SECTION, 160 "var a=true,b=true;a*b", 161 1, 162 eval("var a=true,b=true;a*b") ); 163 // / 164 testcases[tc++] = new TestCase( SECTION, 165 "var a=true,b=true;a/b", 166 1, 167 eval("var a=true,b=true;a/b") ); 168 // & 169 testcases[tc++] = new TestCase( SECTION, 170 "var a=3,b=2;a&b", 171 2, 172 eval("var a=3,b=2;a&b") ); 173 // | 174 testcases[tc++] = new TestCase( SECTION, 175 "var a=4,b=3;a|b", 176 7, 177 eval("var a=4,b=3;a|b") ); 178 179 // | 180 testcases[tc++] = new TestCase( SECTION, 181 "var a=4,b=3;a^b", 182 7, 183 eval("var a=4,b=3;a^b") ); 184 185 // % 186 testcases[tc++] = new TestCase( SECTION, 187 "var a=4,b=3;a|b", 188 1, 189 eval("var a=4,b=3;a%b") ); 190 191 // << 192 testcases[tc++] = new TestCase( SECTION, 193 "var a=4,b=3;a<<b", 194 32, 195 eval("var a=4,b=3;a<<b") ); 196 197 // >> 198 testcases[tc++] = new TestCase( SECTION, 199 "var a=4,b=1;a>>b", 200 2, 201 eval("var a=4,b=1;a>>b") ); 202 203 // >>> 204 testcases[tc++] = new TestCase( SECTION, 205 "var a=1,b=1;a>>>b", 206 0, 207 eval("var a=1,b=1;a>>>b") ); 208 // += 209 testcases[tc++] = new TestCase( SECTION, 210 "var a=4,b=3;a+=b;a", 211 7, 212 eval("var a=4,b=3;a+=b;a") ); 213 214 // -= 215 testcases[tc++] = new TestCase( SECTION, 216 "var a=4,b=3;a-=b;a", 217 1, 218 eval("var a=4,b=3;a-=b;a") ); 219 // *= 220 testcases[tc++] = new TestCase( SECTION, 221 "var a=4,b=3;a*=b;a", 222 12, 223 eval("var a=4,b=3;a*=b;a") ); 224 // += 225 testcases[tc++] = new TestCase( SECTION, 226 "var a=4,b=3;a+=b;a", 227 7, 228 eval("var a=4,b=3;a+=b;a") ); 229 // /= 230 testcases[tc++] = new TestCase( SECTION, 231 "var a=12,b=3;a/=b;a", 232 4, 233 eval("var a=12,b=3;a/=b;a") ); 234 235 // &= 236 testcases[tc++] = new TestCase( SECTION, 237 "var a=4,b=5;a&=b;a", 238 4, 239 eval("var a=4,b=5;a&=b;a") ); 240 241 // |= 242 testcases[tc++] = new TestCase( SECTION, 243 "var a=4,b=5;a&=b;a", 244 5, 245 eval("var a=4,b=5;a|=b;a") ); 246 // ^= 247 testcases[tc++] = new TestCase( SECTION, 248 "var a=4,b=5;a^=b;a", 249 1, 250 eval("var a=4,b=5;a^=b;a") ); 251 // %= 252 testcases[tc++] = new TestCase( SECTION, 253 "var a=12,b=5;a%=b;a", 254 2, 255 eval("var a=12,b=5;a%=b;a") ); 256 // <<= 257 testcases[tc++] = new TestCase( SECTION, 258 "var a=4,b=3;a<<=b;a", 259 32, 260 eval("var a=4,b=3;a<<=b;a") ); 261 262 // >> 263 testcases[tc++] = new TestCase( SECTION, 264 "var a=4,b=1;a>>=b;a", 265 2, 266 eval("var a=4,b=1;a>>=b;a") ); 267 268 // >>> 269 testcases[tc++] = new TestCase( SECTION, 270 "var a=1,b=1;a>>>=b;a", 271 0, 272 eval("var a=1,b=1;a>>>=b;a") ); 273 274 // () 275 testcases[tc++] = new TestCase( SECTION, 276 "var a=4,b=3;(a)", 277 4, 278 eval("var a=4,b=3;(a)") ); 279 // {} 280 testcases[tc++] = new TestCase( SECTION, 281 "var a=4,b=3;{b}", 282 3, 283 eval("var a=4,b=3;{b}") ); 284 285 // [] 286 testcases[tc++] = new TestCase( SECTION, 287 "var a=new Array('hi');a[0]", 288 "hi", 289 eval("var a=new Array('hi');a[0]") ); 290 // [] 291 testcases[tc++] = new TestCase( SECTION, 292 ";", 293 void 0, 294 eval(";") ); 295 test(); 296 297function test() { 298 for ( tc=0; tc < testcases.length; tc++ ) { 299 testcases[tc].passed = writeTestCaseResult( 300 testcases[tc].expect, 301 testcases[tc].actual, 302 testcases[tc].description +" = "+ 303 testcases[tc].actual ); 304 305 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; 306 } 307 stopTest(); 308 return ( testcases ); 309} 310