Home | History | Annotate | Download | only in RegExp
      1 /**
      2  *  File Name:          RegExp/octal-001.js
      3  *  ECMA Section:       15.7.1
      4  *  Description:        Based on ECMA 2 Draft 7 February 1999
      5  *  Simple test cases for matching OctalEscapeSequences.
      6  *  Author:             christine (at) netscape.com
      7  *  Date:               19 February 1999
      8  */
      9     var SECTION = "RegExp/octal-001.js";
     10     var VERSION = "ECMA_2";
     11     var TITLE   = "RegExp patterns that contain OctalEscapeSequences";
     12     var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196";
     13 
     14     startTest();
     15 
     16 
     17 // backreference
     18     AddRegExpCases(
     19         /(.)\1/,
     20         "/(.)\\1/",
     21         "HI!!",
     22         "HI!",
     23         2,
     24         ["!!", "!"] );
     25 
     26     test();
     27 
     28 function AddRegExpCases(
     29     regexp, str_regexp, pattern, str_pattern, index, matches_array ) {
     30 
     31     // prevent a runtime error
     32 
     33     if ( regexp.exec(pattern) == null || matches_array == null ) {
     34         AddTestCase(
     35             regexp + ".exec(" + str_pattern +")",
     36             matches_array,
     37             regexp.exec(pattern) );
     38 
     39         return;
     40     }
     41     AddTestCase(
     42         str_regexp + ".exec(" + str_pattern +").length",
     43         matches_array.length,
     44         regexp.exec(pattern).length );
     45 
     46     AddTestCase(
     47         str_regexp + ".exec(" + str_pattern +").index",
     48         index,
     49         regexp.exec(pattern).index );
     50 
     51     AddTestCase(
     52         str_regexp + ".exec(" + str_pattern +").input",
     53         pattern,
     54         regexp.exec(pattern).input );
     55 
     56     AddTestCase(
     57         str_regexp + ".exec(" + str_pattern +").toString()",
     58         matches_array.toString(),
     59         regexp.exec(pattern).toString() );
     60 /*
     61     var limit = matches_array.length > regexp.exec(pattern).length
     62                 ? matches_array.length
     63                 : regexp.exec(pattern).length;
     64 
     65     for ( var matches = 0; matches < limit; matches++ ) {
     66         AddTestCase(
     67             str_regexp + ".exec(" + str_pattern +")[" + matches +"]",
     68             matches_array[matches],
     69             regexp.exec(pattern)[matches] );
     70     }
     71 */
     72 }
     73