Home | History | Annotate | Download | only in RegExp
      1 /**
      2  *  File Name:          RegExp/octal-002.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-002.js";
     10     var VERSION = "ECMA_2";
     11     var TITLE   = "RegExp patterns that contain OctalEscapeSequences";
     12     var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189";
     13 
     14     startTest();
     15 
     16 // backreference
     17     AddRegExpCases(
     18         /(.)(.)(.)(.)(.)(.)(.)(.)\8/,
     19         "/(.)(.)(.)(.)(.)(.)(.)(.)\\8",
     20         "aabbccaaabbbccc",
     21         "aabbccaaabbbccc",
     22         0,
     23         ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] );
     24 
     25     AddRegExpCases(
     26         /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/,
     27         "/(.)(.)(.)(.)(.)(.)(.)(.)\\9",
     28         "aabbccaabbcc",
     29         "aabbccaabbcc",
     30         0,
     31         ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] );
     32 
     33     AddRegExpCases(
     34         /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/,
     35         "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8",
     36         "aabbccaababcc",
     37         "aabbccaababcc",
     38         0,
     39         ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] );
     40 
     41     test();
     42 
     43 function AddRegExpCases(
     44     regexp, str_regexp, pattern, str_pattern, index, matches_array ) {
     45 
     46     // prevent a runtime error
     47 
     48     if ( regexp.exec(pattern) == null || matches_array == null ) {
     49         AddTestCase(
     50             regexp + ".exec(" + str_pattern +")",
     51             matches_array,
     52             regexp.exec(pattern) );
     53 
     54         return;
     55     }
     56     AddTestCase(
     57         str_regexp + ".exec(" + str_pattern +").length",
     58         matches_array.length,
     59         regexp.exec(pattern).length );
     60 
     61     AddTestCase(
     62         str_regexp + ".exec(" + str_pattern +").index",
     63         index,
     64         regexp.exec(pattern).index );
     65 
     66     AddTestCase(
     67         str_regexp + ".exec(" + str_pattern +").input",
     68         pattern,
     69         regexp.exec(pattern).input );
     70 
     71     AddTestCase(
     72         str_regexp + ".exec(" + str_pattern +").toString()",
     73         matches_array.toString(),
     74         regexp.exec(pattern).toString() );
     75 /*
     76     var limit = matches_array.length > regexp.exec(pattern).length
     77                 ? matches_array.length
     78                 : regexp.exec(pattern).length;
     79 
     80     for ( var matches = 0; matches < limit; matches++ ) {
     81         AddTestCase(
     82             str_regexp + ".exec(" + str_pattern +")[" + matches +"]",
     83             matches_array[matches],
     84             regexp.exec(pattern)[matches] );
     85     }
     86 */
     87 }
     88