octal-002.js (2499B)
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-002.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-002.js"; 16 var TITLE = "RegExp patterns that contain OctalEscapeSequences"; 17 var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; 18 19 printBugNumber(BUGNUMBER); 20 21 // backreference 22 AddRegExpCases( 23 /(.)(.)(.)(.)(.)(.)(.)(.)\8/, 24 "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", 25 "aabbccaaabbbccc", 26 "aabbccaaabbbccc", 27 0, 28 ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); 29 30 AddRegExpCases( 31 /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, 32 "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", 33 "aabbccaabbcc", 34 "aabbccaabbcc", 35 0, 36 ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); 37 38 AddRegExpCases( 39 /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, 40 "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", 41 "aabbccaababcc", 42 "aabbccaababcc", 43 0, 44 ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); 45 46 test(); 47 48 function AddRegExpCases( 49 regexp, str_regexp, pattern, str_pattern, index, matches_array ) { 50 51 // prevent a runtime error 52 53 if ( regexp.exec(pattern) == null || matches_array == null ) { 54 AddTestCase( 55 regexp + ".exec(" + str_pattern +")", 56 matches_array, 57 regexp.exec(pattern) ); 58 59 return; 60 } 61 AddTestCase( 62 str_regexp + ".exec(" + str_pattern +").length", 63 matches_array.length, 64 regexp.exec(pattern).length ); 65 66 AddTestCase( 67 str_regexp + ".exec(" + str_pattern +").index", 68 index, 69 regexp.exec(pattern).index ); 70 71 AddTestCase( 72 str_regexp + ".exec(" + str_pattern +").input", 73 pattern, 74 regexp.exec(pattern).input ); 75 76 AddTestCase( 77 str_regexp + ".exec(" + str_pattern +").toString()", 78 matches_array.toString(), 79 regexp.exec(pattern).toString() ); 80 /* 81 var limit = matches_array.length > regexp.exec(pattern).length 82 ? matches_array.length 83 : regexp.exec(pattern).length; 84 85 for ( var matches = 0; matches < limit; matches++ ) { 86 AddTestCase( 87 str_regexp + ".exec(" + str_pattern +")[" + matches +"]", 88 matches_array[matches], 89 regexp.exec(pattern)[matches] ); 90 } 91 */ 92 }