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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_2/RegExp/octal-002.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 + *  File Name:          RegExp/octal-002.js
    1.12 + *  ECMA Section:       15.7.1
    1.13 + *  Description:        Based on ECMA 2 Draft 7 February 1999
    1.14 + *  Simple test cases for matching OctalEscapeSequences.
    1.15 + *  Author:             christine@netscape.com
    1.16 + *  Date:               19 February 1999
    1.17 + */
    1.18 +var SECTION = "RegExp/octal-002.js";
    1.19 +var VERSION = "ECMA_2";
    1.20 +var TITLE   = "RegExp patterns that contain OctalEscapeSequences";
    1.21 +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189";
    1.22 +
    1.23 +startTest();
    1.24 +
    1.25 +// backreference
    1.26 +AddRegExpCases(
    1.27 +  /(.)(.)(.)(.)(.)(.)(.)(.)\8/,
    1.28 +  "/(.)(.)(.)(.)(.)(.)(.)(.)\\8",
    1.29 +  "aabbccaaabbbccc",
    1.30 +  "aabbccaaabbbccc",
    1.31 +  0,
    1.32 +  ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] );
    1.33 +
    1.34 +AddRegExpCases(
    1.35 +  /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/,
    1.36 +  "/(.)(.)(.)(.)(.)(.)(.)(.)\\9",
    1.37 +  "aabbccaabbcc",
    1.38 +  "aabbccaabbcc",
    1.39 +  0,
    1.40 +  ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] );
    1.41 +
    1.42 +AddRegExpCases(
    1.43 +  /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/,
    1.44 +  "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8",
    1.45 +  "aabbccaababcc",
    1.46 +  "aabbccaababcc",
    1.47 +  0,
    1.48 +  ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] );
    1.49 +
    1.50 +test();
    1.51 +
    1.52 +function AddRegExpCases(
    1.53 +  regexp, str_regexp, pattern, str_pattern, index, matches_array ) {
    1.54 +
    1.55 +  // prevent a runtime error
    1.56 +
    1.57 +  if ( regexp.exec(pattern) == null || matches_array == null ) {
    1.58 +    AddTestCase(
    1.59 +      regexp + ".exec(" + str_pattern +")",
    1.60 +      matches_array,
    1.61 +      regexp.exec(pattern) );
    1.62 +
    1.63 +    return;
    1.64 +  }
    1.65 +  AddTestCase(
    1.66 +    str_regexp + ".exec(" + str_pattern +").length",
    1.67 +    matches_array.length,
    1.68 +    regexp.exec(pattern).length );
    1.69 +
    1.70 +  AddTestCase(
    1.71 +    str_regexp + ".exec(" + str_pattern +").index",
    1.72 +    index,
    1.73 +    regexp.exec(pattern).index );
    1.74 +
    1.75 +  AddTestCase(
    1.76 +    str_regexp + ".exec(" + str_pattern +").input",
    1.77 +    pattern,
    1.78 +    regexp.exec(pattern).input );
    1.79 +
    1.80 +  AddTestCase(
    1.81 +    str_regexp + ".exec(" + str_pattern +").toString()",
    1.82 +    matches_array.toString(),
    1.83 +    regexp.exec(pattern).toString() );
    1.84 +/*
    1.85 +  var limit = matches_array.length > regexp.exec(pattern).length
    1.86 +  ? matches_array.length
    1.87 +  : regexp.exec(pattern).length;
    1.88 +
    1.89 +  for ( var matches = 0; matches < limit; matches++ ) {
    1.90 +  AddTestCase(
    1.91 +  str_regexp + ".exec(" + str_pattern +")[" + matches +"]",
    1.92 +  matches_array[matches],
    1.93 +  regexp.exec(pattern)[matches] );
    1.94 +  }
    1.95 +*/
    1.96 +}

mercurial