1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/LexicalConventions/7.6.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,279 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 7.6.js 1.12 + ECMA Section: Punctuators 1.13 + Description: 1.14 + 1.15 + This tests verifies that all ECMA punctutors are recognized as a 1.16 + token separator, but does not attempt to verify the functionality 1.17 + of any punctuator. 1.18 + 1.19 + Author: christine@netscape.com 1.20 + Date: 12 november 1997 1.21 +*/ 1.22 + 1.23 +var SECTION = "7.6"; 1.24 +var VERSION = "ECMA_1"; 1.25 +startTest(); 1.26 +var TITLE = "Punctuators"; 1.27 + 1.28 +writeHeaderToLog( SECTION + " "+ TITLE); 1.29 + 1.30 +// == 1.31 +new TestCase( SECTION, 1.32 + "var c,d;c==d", 1.33 + true, 1.34 + eval("var c,d;c==d") ); 1.35 + 1.36 +// = 1.37 + 1.38 +new TestCase( SECTION, 1.39 + "var a=true;a", 1.40 + true, 1.41 + eval("var a=true;a") ); 1.42 + 1.43 +// > 1.44 +new TestCase( SECTION, 1.45 + "var a=true,b=false;a>b", 1.46 + true, 1.47 + eval("var a=true,b=false;a>b") ); 1.48 + 1.49 +// < 1.50 +new TestCase( SECTION, 1.51 + "var a=true,b=false;a<b", 1.52 + false, 1.53 + eval("var a=true,b=false;a<b") ); 1.54 + 1.55 +// <= 1.56 +new TestCase( SECTION, 1.57 + "var a=0xFFFF,b=0X0FFF;a<=b", 1.58 + false, 1.59 + eval("var a=0xFFFF,b=0X0FFF;a<=b") ); 1.60 + 1.61 +// >= 1.62 +new TestCase( SECTION, 1.63 + "var a=0xFFFF,b=0XFFFE;a>=b", 1.64 + true, 1.65 + eval("var a=0xFFFF,b=0XFFFE;a>=b") ); 1.66 + 1.67 +// != 1.68 +new TestCase( SECTION, 1.69 + "var a=true,b=false;a!=b", 1.70 + true, 1.71 + eval("var a=true,b=false;a!=b") ); 1.72 + 1.73 +new TestCase( SECTION, 1.74 + "var a=false,b=false;a!=b", 1.75 + false, 1.76 + eval("var a=false,b=false;a!=b") ); 1.77 +// , 1.78 +new TestCase( SECTION, 1.79 + "var a=true,b=false;a,b", 1.80 + false, 1.81 + eval("var a=true,b=false;a,b") ); 1.82 +// ! 1.83 +new TestCase( SECTION, 1.84 + "var a=true,b=false;!a", 1.85 + false, 1.86 + eval("var a=true,b=false;!a") ); 1.87 + 1.88 +// ~ 1.89 +new TestCase( SECTION, 1.90 + "var a=true;~a", 1.91 + -2, 1.92 + eval("var a=true;~a") ); 1.93 +// ? 1.94 +new TestCase( SECTION, 1.95 + "var a=true; (a ? 'PASS' : '')", 1.96 + "PASS", 1.97 + eval("var a=true; (a ? 'PASS' : '')") ); 1.98 + 1.99 +// : 1.100 + 1.101 +new TestCase( SECTION, 1.102 + "var a=false; (a ? 'FAIL' : 'PASS')", 1.103 + "PASS", 1.104 + eval("var a=false; (a ? 'FAIL' : 'PASS')") ); 1.105 +// . 1.106 + 1.107 +new TestCase( SECTION, 1.108 + "var a=Number;a.NaN", 1.109 + NaN, 1.110 + eval("var a=Number;a.NaN") ); 1.111 + 1.112 +// && 1.113 +new TestCase( SECTION, 1.114 + "var a=true,b=true;if(a&&b)'PASS';else'FAIL'", 1.115 + "PASS", 1.116 + eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") ); 1.117 + 1.118 +// || 1.119 +new TestCase( SECTION, 1.120 + "var a=false,b=false;if(a||b)'FAIL';else'PASS'", 1.121 + "PASS", 1.122 + eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") ); 1.123 +// ++ 1.124 +new TestCase( SECTION, 1.125 + "var a=false,b=false;++a", 1.126 + 1, 1.127 + eval("var a=false,b=false;++a") ); 1.128 +// -- 1.129 +new TestCase( SECTION, 1.130 + "var a=true,b=false--a", 1.131 + 0, 1.132 + eval("var a=true,b=false;--a") ); 1.133 +// + 1.134 + 1.135 +new TestCase( SECTION, 1.136 + "var a=true,b=true;a+b", 1.137 + 2, 1.138 + eval("var a=true,b=true;a+b") ); 1.139 +// - 1.140 +new TestCase( SECTION, 1.141 + "var a=true,b=true;a-b", 1.142 + 0, 1.143 + eval("var a=true,b=true;a-b") ); 1.144 +// * 1.145 +new TestCase( SECTION, 1.146 + "var a=true,b=true;a*b", 1.147 + 1, 1.148 + eval("var a=true,b=true;a*b") ); 1.149 +// / 1.150 +new TestCase( SECTION, 1.151 + "var a=true,b=true;a/b", 1.152 + 1, 1.153 + eval("var a=true,b=true;a/b") ); 1.154 +// & 1.155 +new TestCase( SECTION, 1.156 + "var a=3,b=2;a&b", 1.157 + 2, 1.158 + eval("var a=3,b=2;a&b") ); 1.159 +// | 1.160 +new TestCase( SECTION, 1.161 + "var a=4,b=3;a|b", 1.162 + 7, 1.163 + eval("var a=4,b=3;a|b") ); 1.164 + 1.165 +// | 1.166 +new TestCase( SECTION, 1.167 + "var a=4,b=3;a^b", 1.168 + 7, 1.169 + eval("var a=4,b=3;a^b") ); 1.170 + 1.171 +// % 1.172 +new TestCase( SECTION, 1.173 + "var a=4,b=3;a|b", 1.174 + 1, 1.175 + eval("var a=4,b=3;a%b") ); 1.176 + 1.177 +// << 1.178 +new TestCase( SECTION, 1.179 + "var a=4,b=3;a<<b", 1.180 + 32, 1.181 + eval("var a=4,b=3;a<<b") ); 1.182 + 1.183 +// >> 1.184 +new TestCase( SECTION, 1.185 + "var a=4,b=1;a>>b", 1.186 + 2, 1.187 + eval("var a=4,b=1;a>>b") ); 1.188 + 1.189 +// >>> 1.190 +new TestCase( SECTION, 1.191 + "var a=1,b=1;a>>>b", 1.192 + 0, 1.193 + eval("var a=1,b=1;a>>>b") ); 1.194 +// += 1.195 +new TestCase( SECTION, 1.196 + "var a=4,b=3;a+=b;a", 1.197 + 7, 1.198 + eval("var a=4,b=3;a+=b;a") ); 1.199 + 1.200 +// -= 1.201 +new TestCase( SECTION, 1.202 + "var a=4,b=3;a-=b;a", 1.203 + 1, 1.204 + eval("var a=4,b=3;a-=b;a") ); 1.205 +// *= 1.206 +new TestCase( SECTION, 1.207 + "var a=4,b=3;a*=b;a", 1.208 + 12, 1.209 + eval("var a=4,b=3;a*=b;a") ); 1.210 +// += 1.211 +new TestCase( SECTION, 1.212 + "var a=4,b=3;a+=b;a", 1.213 + 7, 1.214 + eval("var a=4,b=3;a+=b;a") ); 1.215 +// /= 1.216 +new TestCase( SECTION, 1.217 + "var a=12,b=3;a/=b;a", 1.218 + 4, 1.219 + eval("var a=12,b=3;a/=b;a") ); 1.220 + 1.221 +// &= 1.222 +new TestCase( SECTION, 1.223 + "var a=4,b=5;a&=b;a", 1.224 + 4, 1.225 + eval("var a=4,b=5;a&=b;a") ); 1.226 + 1.227 +// |= 1.228 +new TestCase( SECTION, 1.229 + "var a=4,b=5;a&=b;a", 1.230 + 5, 1.231 + eval("var a=4,b=5;a|=b;a") ); 1.232 +// ^= 1.233 +new TestCase( SECTION, 1.234 + "var a=4,b=5;a^=b;a", 1.235 + 1, 1.236 + eval("var a=4,b=5;a^=b;a") ); 1.237 +// %= 1.238 +new TestCase( SECTION, 1.239 + "var a=12,b=5;a%=b;a", 1.240 + 2, 1.241 + eval("var a=12,b=5;a%=b;a") ); 1.242 +// <<= 1.243 +new TestCase( SECTION, 1.244 + "var a=4,b=3;a<<=b;a", 1.245 + 32, 1.246 + eval("var a=4,b=3;a<<=b;a") ); 1.247 + 1.248 +// >> 1.249 +new TestCase( SECTION, 1.250 + "var a=4,b=1;a>>=b;a", 1.251 + 2, 1.252 + eval("var a=4,b=1;a>>=b;a") ); 1.253 + 1.254 +// >>> 1.255 +new TestCase( SECTION, 1.256 + "var a=1,b=1;a>>>=b;a", 1.257 + 0, 1.258 + eval("var a=1,b=1;a>>>=b;a") ); 1.259 + 1.260 +// () 1.261 +new TestCase( SECTION, 1.262 + "var a=4,b=3;(a)", 1.263 + 4, 1.264 + eval("var a=4,b=3;(a)") ); 1.265 +// {} 1.266 +new TestCase( SECTION, 1.267 + "var a=4,b=3;{b}", 1.268 + 3, 1.269 + eval("var a=4,b=3;{b}") ); 1.270 + 1.271 +// [] 1.272 +new TestCase( SECTION, 1.273 + "var a=new Array('hi');a[0]", 1.274 + "hi", 1.275 + eval("var a=new Array('hi');a[0]") ); 1.276 +// [] 1.277 +new TestCase( SECTION, 1.278 + ";", 1.279 + void 0, 1.280 + eval(";") ); 1.281 +test(); 1.282 +