1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_2/RegExp/properties-002.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,129 @@ 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: RegExp/properties-002.js 1.12 + * ECMA Section: 15.7.6.js 1.13 + * Description: Based on ECMA 2 Draft 7 February 1999 1.14 + * 1.15 + * Author: christine@netscape.com 1.16 + * Date: 19 February 1999 1.17 + */ 1.18 +//----------------------------------------------------------------------------- 1.19 +var SECTION = "RegExp/properties-002.js"; 1.20 +var VERSION = "ECMA_2"; 1.21 +var TITLE = "Properties of RegExp Instances"; 1.22 +var BUGNUMBER ="124339"; 1.23 + 1.24 +startTest(); 1.25 + 1.26 +re_1 = /\cA?/g; 1.27 +re_1.lastIndex = Math.pow(2,31); 1.28 +AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) ); 1.29 + 1.30 +re_2 = /\w*/i; 1.31 +re_2.lastIndex = Math.pow(2,32) -1; 1.32 +AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 ); 1.33 + 1.34 +re_3 = /\*{0,80}/m; 1.35 +re_3.lastIndex = Math.pow(2,31) -1; 1.36 +AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 ); 1.37 + 1.38 +re_4 = /^./gim; 1.39 +re_4.lastIndex = Math.pow(2,30) -1; 1.40 +AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 ); 1.41 + 1.42 +re_5 = /\B/; 1.43 +re_5.lastIndex = Math.pow(2,30); 1.44 +AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) ); 1.45 + 1.46 +/* 1.47 + * Brendan: "need to test cases Math.pow(2,32) and greater to see 1.48 + * whether they round-trip." Reason: thanks to the work done in 1.49 + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex 1.50 + * is now stored as a double instead of a uint32_t (unsigned integer). 1.51 + * 1.52 + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go 1.53 + * all the way up to Number.MAX_VALUE. So that's why we need cases 1.54 + * between those two numbers. 1.55 + * 1.56 + */ 1.57 +re_6 = /\B/; 1.58 +re_6.lastIndex = Math.pow(2,32); 1.59 +AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) ); 1.60 + 1.61 +re_7 = /\B/; 1.62 +re_7.lastIndex = Math.pow(2,32) + 1; 1.63 +AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 ); 1.64 + 1.65 +re_8 = /\B/; 1.66 +re_8.lastIndex = Math.pow(2,32) * 2; 1.67 +AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 ); 1.68 + 1.69 +re_9 = /\B/; 1.70 +re_9.lastIndex = Math.pow(2,40); 1.71 +AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) ); 1.72 + 1.73 +re_10 = /\B/; 1.74 +re_10.lastIndex = Number.MAX_VALUE; 1.75 +AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE ); 1.76 + 1.77 + 1.78 + 1.79 +//----------------------------------------------------------------------------- 1.80 +test(); 1.81 +//----------------------------------------------------------------------------- 1.82 + 1.83 + 1.84 + 1.85 +function AddRegExpCases( re, s, g, i, m, l ){ 1.86 + 1.87 + AddTestCase( re + ".test == RegExp.prototype.test", 1.88 + true, 1.89 + re.test == RegExp.prototype.test ); 1.90 + 1.91 + AddTestCase( re + ".toString == RegExp.prototype.toString", 1.92 + true, 1.93 + re.toString == RegExp.prototype.toString ); 1.94 + 1.95 + AddTestCase( re + ".contructor == RegExp.prototype.constructor", 1.96 + true, 1.97 + re.constructor == RegExp.prototype.constructor ); 1.98 + 1.99 + AddTestCase( re + ".compile == RegExp.prototype.compile", 1.100 + true, 1.101 + re.compile == RegExp.prototype.compile ); 1.102 + 1.103 + AddTestCase( re + ".exec == RegExp.prototype.exec", 1.104 + true, 1.105 + re.exec == RegExp.prototype.exec ); 1.106 + 1.107 + // properties 1.108 + 1.109 + AddTestCase( re + ".source", 1.110 + s, 1.111 + re.source ); 1.112 + 1.113 + AddTestCase( re + ".toString()", 1.114 + "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), 1.115 + re.toString() ); 1.116 + 1.117 + AddTestCase( re + ".global", 1.118 + g, 1.119 + re.global ); 1.120 + 1.121 + AddTestCase( re + ".ignoreCase", 1.122 + i, 1.123 + re.ignoreCase ); 1.124 + 1.125 + AddTestCase( re + ".multiline", 1.126 + m, 1.127 + re.multiline); 1.128 + 1.129 + AddTestCase( re + ".lastIndex", 1.130 + l, 1.131 + re.lastIndex ); 1.132 +}