js/src/tests/ecma_3/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_3/RegExp/octal-001.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,102 @@
     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 + * Date:    18 July 2002
    1.12 + * SUMMARY: Testing octal sequences in regexps
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=141078
    1.14 + *
    1.15 + */
    1.16 +//-----------------------------------------------------------------------------
    1.17 +var i = 0;
    1.18 +var BUGNUMBER = 141078;
    1.19 +var summary = 'Testing octal sequences in regexps';
    1.20 +var status = '';
    1.21 +var statusmessages = new Array();
    1.22 +var pattern = '';
    1.23 +var patterns = new Array();
    1.24 +var string = '';
    1.25 +var strings = new Array();
    1.26 +var actualmatch = '';
    1.27 +var actualmatches = new Array();
    1.28 +var expectedmatch = '';
    1.29 +var expectedmatches = new Array();
    1.30 +
    1.31 +
    1.32 +status = inSection(1);
    1.33 +pattern = /\240/;
    1.34 +string = 'abc';
    1.35 +actualmatch = string.match(pattern);
    1.36 +expectedmatch = null;
    1.37 +addThis();
    1.38 +
    1.39 +/*
    1.40 + * In the following sections, we test the octal escape sequence '\052'.
    1.41 + * This is character code 42, representing the asterisk character '*'.
    1.42 + * The Unicode escape for it would be '\u002A', the hex escape '\x2A'.
    1.43 + */
    1.44 +status = inSection(2);
    1.45 +pattern = /ab\052c/;
    1.46 +string = 'ab*c';
    1.47 +actualmatch = string.match(pattern);
    1.48 +expectedmatch = Array('ab*c');
    1.49 +addThis();
    1.50 +
    1.51 +status = inSection(3);
    1.52 +pattern = /ab\052*c/;
    1.53 +string = 'abc';
    1.54 +actualmatch = string.match(pattern);
    1.55 +expectedmatch = Array('abc');
    1.56 +addThis();
    1.57 +
    1.58 +status = inSection(4);
    1.59 +pattern = /ab(\052)+c/;
    1.60 +string = 'ab****c';
    1.61 +actualmatch = string.match(pattern);
    1.62 +expectedmatch = Array('ab****c', '*');
    1.63 +addThis();
    1.64 +
    1.65 +status = inSection(5);
    1.66 +pattern = /ab((\052)+)c/;
    1.67 +string = 'ab****c';
    1.68 +actualmatch = string.match(pattern);
    1.69 +expectedmatch = Array('ab****c', '****', '*');
    1.70 +addThis();
    1.71 +
    1.72 +status = inSection(6);
    1.73 +pattern = /(?:\052)c/;
    1.74 +string = 'ab****c';
    1.75 +actualmatch = string.match(pattern);
    1.76 +expectedmatch = Array('*c');
    1.77 +addThis();
    1.78 +
    1.79 +
    1.80 +
    1.81 +//-----------------------------------------------------------------------------
    1.82 +test();
    1.83 +//-----------------------------------------------------------------------------
    1.84 +
    1.85 +
    1.86 +
    1.87 +function addThis()
    1.88 +{
    1.89 +  statusmessages[i] = status;
    1.90 +  patterns[i] = pattern;
    1.91 +  strings[i] = string;
    1.92 +  actualmatches[i] = actualmatch;
    1.93 +  expectedmatches[i] = expectedmatch;
    1.94 +  i++;
    1.95 +}
    1.96 +
    1.97 +
    1.98 +function test()
    1.99 +{
   1.100 +  enterFunc('test');
   1.101 +  printBugNumber(BUGNUMBER);
   1.102 +  printStatus(summary);
   1.103 +  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
   1.104 +  exitFunc ('test');
   1.105 +}

mercurial