js/src/tests/ecma_2/RegExp/octal-002.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
     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 VERSION = "ECMA_2";
    17 var TITLE   = "RegExp patterns that contain OctalEscapeSequences";
    18 var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189";
    20 startTest();
    22 // backreference
    23 AddRegExpCases(
    24   /(.)(.)(.)(.)(.)(.)(.)(.)\8/,
    25   "/(.)(.)(.)(.)(.)(.)(.)(.)\\8",
    26   "aabbccaaabbbccc",
    27   "aabbccaaabbbccc",
    28   0,
    29   ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] );
    31 AddRegExpCases(
    32   /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/,
    33   "/(.)(.)(.)(.)(.)(.)(.)(.)\\9",
    34   "aabbccaabbcc",
    35   "aabbccaabbcc",
    36   0,
    37   ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] );
    39 AddRegExpCases(
    40   /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/,
    41   "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8",
    42   "aabbccaababcc",
    43   "aabbccaababcc",
    44   0,
    45   ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] );
    47 test();
    49 function AddRegExpCases(
    50   regexp, str_regexp, pattern, str_pattern, index, matches_array ) {
    52   // prevent a runtime error
    54   if ( regexp.exec(pattern) == null || matches_array == null ) {
    55     AddTestCase(
    56       regexp + ".exec(" + str_pattern +")",
    57       matches_array,
    58       regexp.exec(pattern) );
    60     return;
    61   }
    62   AddTestCase(
    63     str_regexp + ".exec(" + str_pattern +").length",
    64     matches_array.length,
    65     regexp.exec(pattern).length );
    67   AddTestCase(
    68     str_regexp + ".exec(" + str_pattern +").index",
    69     index,
    70     regexp.exec(pattern).index );
    72   AddTestCase(
    73     str_regexp + ".exec(" + str_pattern +").input",
    74     pattern,
    75     regexp.exec(pattern).input );
    77   AddTestCase(
    78     str_regexp + ".exec(" + str_pattern +").toString()",
    79     matches_array.toString(),
    80     regexp.exec(pattern).toString() );
    81 /*
    82   var limit = matches_array.length > regexp.exec(pattern).length
    83   ? matches_array.length
    84   : regexp.exec(pattern).length;
    86   for ( var matches = 0; matches < limit; matches++ ) {
    87   AddTestCase(
    88   str_regexp + ".exec(" + str_pattern +")[" + matches +"]",
    89   matches_array[matches],
    90   regexp.exec(pattern)[matches] );
    91   }
    92 */
    93 }

mercurial