1/** 2 * File Name: RegExp/hex-001.js 3 * ECMA Section: 15.7.3.1 4 * Description: Based on ECMA 2 Draft 7 February 1999 5 * Positive test cases for constructing a RegExp object 6 * Author: christine@netscape.com 7 * Date: 19 February 1999 8 */ 9 var SECTION = "RegExp/hex-001"; 10 var VERSION = "ECMA_2"; 11 var TITLE = "RegExp patterns that contain HexicdecimalEscapeSequences"; 12 13 startTest(); 14 15 // These examples come from 15.7.1, HexidecimalEscapeSequence 16 17 AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); 18 AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); 19 AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] ); 20 21 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); 22 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); 23 AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]); 24 AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] ); 25 26 test(); 27 28function AddRegExpCases( 29 regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { 30 31 // prevent a runtime error 32 33 if ( regexp.exec(pattern) == null || matches_array == null ) { 34 AddTestCase( 35 str_regexp + ".exec(" + pattern +")", 36 matches_array, 37 regexp.exec(pattern) ); 38 39 return; 40 } 41 42 AddTestCase( 43 str_regexp + ".exec(" + str_pattern +").length", 44 length, 45 regexp.exec(pattern).length ); 46 47 AddTestCase( 48 str_regexp + ".exec(" + str_pattern +").index", 49 index, 50 regexp.exec(pattern).index ); 51 52 AddTestCase( 53 str_regexp + ".exec(" + str_pattern +").input", 54 pattern, 55 regexp.exec(pattern).input ); 56 57 for ( var matches = 0; matches < matches_array.length; matches++ ) { 58 AddTestCase( 59 str_regexp + ".exec(" + str_pattern +")[" + matches +"]", 60 matches_array[matches], 61 regexp.exec(pattern)[matches] ); 62 } 63} 64