michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: * File Name: RegExp/octal-002.js michael@0: * ECMA Section: 15.7.1 michael@0: * Description: Based on ECMA 2 Draft 7 February 1999 michael@0: * Simple test cases for matching OctalEscapeSequences. michael@0: * Author: christine@netscape.com michael@0: * Date: 19 February 1999 michael@0: */ michael@0: var SECTION = "RegExp/octal-002.js"; michael@0: var VERSION = "ECMA_2"; michael@0: var TITLE = "RegExp patterns that contain OctalEscapeSequences"; michael@0: var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; michael@0: michael@0: startTest(); michael@0: michael@0: // backreference michael@0: AddRegExpCases( michael@0: /(.)(.)(.)(.)(.)(.)(.)(.)\8/, michael@0: "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", michael@0: "aabbccaaabbbccc", michael@0: "aabbccaaabbbccc", michael@0: 0, michael@0: ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); michael@0: michael@0: AddRegExpCases( michael@0: /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, michael@0: "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", michael@0: "aabbccaabbcc", michael@0: "aabbccaabbcc", michael@0: 0, michael@0: ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); michael@0: michael@0: AddRegExpCases( michael@0: /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, michael@0: "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", michael@0: "aabbccaababcc", michael@0: "aabbccaababcc", michael@0: 0, michael@0: ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); michael@0: michael@0: test(); michael@0: michael@0: function AddRegExpCases( michael@0: regexp, str_regexp, pattern, str_pattern, index, matches_array ) { michael@0: michael@0: // prevent a runtime error michael@0: michael@0: if ( regexp.exec(pattern) == null || matches_array == null ) { michael@0: AddTestCase( michael@0: regexp + ".exec(" + str_pattern +")", michael@0: matches_array, michael@0: regexp.exec(pattern) ); michael@0: michael@0: return; michael@0: } michael@0: AddTestCase( michael@0: str_regexp + ".exec(" + str_pattern +").length", michael@0: matches_array.length, michael@0: regexp.exec(pattern).length ); michael@0: michael@0: AddTestCase( michael@0: str_regexp + ".exec(" + str_pattern +").index", michael@0: index, michael@0: regexp.exec(pattern).index ); michael@0: michael@0: AddTestCase( michael@0: str_regexp + ".exec(" + str_pattern +").input", michael@0: pattern, michael@0: regexp.exec(pattern).input ); michael@0: michael@0: AddTestCase( michael@0: str_regexp + ".exec(" + str_pattern +").toString()", michael@0: matches_array.toString(), michael@0: regexp.exec(pattern).toString() ); michael@0: /* michael@0: var limit = matches_array.length > regexp.exec(pattern).length michael@0: ? matches_array.length michael@0: : regexp.exec(pattern).length; michael@0: michael@0: for ( var matches = 0; matches < limit; matches++ ) { michael@0: AddTestCase( michael@0: str_regexp + ".exec(" + str_pattern +")[" + matches +"]", michael@0: matches_array[matches], michael@0: regexp.exec(pattern)[matches] ); michael@0: } michael@0: */ michael@0: }