js/src/tests/ecma/LexicalConventions/7.6.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial