js/src/tests/ecma_2/RegExp/octal-001.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-001.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     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-001.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-001.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=346196";
    1.22 +
    1.23 +startTest();
    1.24 +
    1.25 +
    1.26 +// backreference
    1.27 +AddRegExpCases(
    1.28 +  /(.)\1/,
    1.29 +  "/(.)\\1/",
    1.30 +  "HI!!",
    1.31 +  "HI!",
    1.32 +  2,
    1.33 +  ["!!", "!"] );
    1.34 +
    1.35 +test();
    1.36 +
    1.37 +function AddRegExpCases(
    1.38 +  regexp, str_regexp, pattern, str_pattern, index, matches_array ) {
    1.39 +
    1.40 +  // prevent a runtime error
    1.41 +
    1.42 +  if ( regexp.exec(pattern) == null || matches_array == null ) {
    1.43 +    AddTestCase(
    1.44 +      regexp + ".exec(" + str_pattern +")",
    1.45 +      matches_array,
    1.46 +      regexp.exec(pattern) );
    1.47 +
    1.48 +    return;
    1.49 +  }
    1.50 +  AddTestCase(
    1.51 +    str_regexp + ".exec(" + str_pattern +").length",
    1.52 +    matches_array.length,
    1.53 +    regexp.exec(pattern).length );
    1.54 +
    1.55 +  AddTestCase(
    1.56 +    str_regexp + ".exec(" + str_pattern +").index",
    1.57 +    index,
    1.58 +    regexp.exec(pattern).index );
    1.59 +
    1.60 +  AddTestCase(
    1.61 +    str_regexp + ".exec(" + str_pattern +").input",
    1.62 +    pattern,
    1.63 +    regexp.exec(pattern).input );
    1.64 +
    1.65 +  AddTestCase(
    1.66 +    str_regexp + ".exec(" + str_pattern +").toString()",
    1.67 +    matches_array.toString(),
    1.68 +    regexp.exec(pattern).toString() );
    1.69 +/*
    1.70 +  var limit = matches_array.length > regexp.exec(pattern).length
    1.71 +  ? matches_array.length
    1.72 +  : regexp.exec(pattern).length;
    1.73 +
    1.74 +  for ( var matches = 0; matches < limit; matches++ ) {
    1.75 +  AddTestCase(
    1.76 +  str_regexp + ".exec(" + str_pattern +")[" + matches +"]",
    1.77 +  matches_array[matches],
    1.78 +  regexp.exec(pattern)[matches] );
    1.79 +  }
    1.80 +*/
    1.81 +}

mercurial