octal-001.js (2005B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 7 /** 8 * File Name: RegExp/octal-001.js 9 * ECMA Section: 15.7.1 10 * Description: Based on ECMA 2 Draft 7 February 1999 11 * Simple test cases for matching OctalEscapeSequences. 12 * Author: christine@netscape.com 13 * Date: 19 February 1999 14 */ 15 var SECTION = "RegExp/octal-001.js"; 16 var TITLE = "RegExp patterns that contain OctalEscapeSequences"; 17 var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196"; 18 19 printBugNumber(BUGNUMBER); 20 21 22 // backreference 23 AddRegExpCases( 24 /(.)\1/, 25 "/(.)\\1/", 26 "HI!!", 27 "HI!", 28 2, 29 ["!!", "!"] ); 30 31 test(); 32 33 function AddRegExpCases( 34 regexp, str_regexp, pattern, str_pattern, index, matches_array ) { 35 36 // prevent a runtime error 37 38 if ( regexp.exec(pattern) == null || matches_array == null ) { 39 AddTestCase( 40 regexp + ".exec(" + str_pattern +")", 41 matches_array, 42 regexp.exec(pattern) ); 43 44 return; 45 } 46 AddTestCase( 47 str_regexp + ".exec(" + str_pattern +").length", 48 matches_array.length, 49 regexp.exec(pattern).length ); 50 51 AddTestCase( 52 str_regexp + ".exec(" + str_pattern +").index", 53 index, 54 regexp.exec(pattern).index ); 55 56 AddTestCase( 57 str_regexp + ".exec(" + str_pattern +").input", 58 pattern, 59 regexp.exec(pattern).input ); 60 61 AddTestCase( 62 str_regexp + ".exec(" + str_pattern +").toString()", 63 matches_array.toString(), 64 regexp.exec(pattern).toString() ); 65 /* 66 var limit = matches_array.length > regexp.exec(pattern).length 67 ? matches_array.length 68 : regexp.exec(pattern).length; 69 70 for ( var matches = 0; matches < limit; matches++ ) { 71 AddTestCase( 72 str_regexp + ".exec(" + str_pattern +")[" + matches +"]", 73 matches_array[matches], 74 regexp.exec(pattern)[matches] ); 75 } 76 */ 77 }