js/src/tests/ecma_3/RegExp/15.10.4.1-6.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/15.10.4.1-6.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     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 +  15.10.4.1 new RegExp(pattern, flags)
    1.11 +
    1.12 +  If F contains any character other than "g", "i", or" m", or if it
    1.13 +  contains the same one more than once, then throw a SyntaxError
    1.14 +  exception.
    1.15 +*/
    1.16 +
    1.17 +//-----------------------------------------------------------------------------
    1.18 +var BUGNUMBER = 476940;
    1.19 +var summary = 'Section 15.10.4.1 - RegExp with invalid flags';
    1.20 +var actual = '';
    1.21 +var expect = '';
    1.22 +
    1.23 +
    1.24 +//-----------------------------------------------------------------------------
    1.25 +test();
    1.26 +//-----------------------------------------------------------------------------
    1.27 +
    1.28 +function test()
    1.29 +{
    1.30 +  enterFunc ('test');
    1.31 +  printBugNumber(BUGNUMBER);
    1.32 +  printStatus (summary);
    1.33 +
    1.34 +  var invalidflags = ['ii', 'gg', 'mm', 'a'];
    1.35 +
    1.36 +  for (var i = 0; i < invalidflags.length; i++)
    1.37 +  {
    1.38 +    var flag = invalidflags[i];
    1.39 +    expect = 'SyntaxError: invalid regular expression flag ' + flag.charAt(0);
    1.40 +    actual = '';
    1.41 +    try
    1.42 +    {
    1.43 +      new RegExp('bar', flag);
    1.44 +    }
    1.45 +    catch(ex)
    1.46 +    {
    1.47 +      actual = ex + '';
    1.48 +    }
    1.49 +    reportCompare(expect, actual, summary + 
    1.50 +                  ': new RegExp("bar", "' + flag + '")');
    1.51 +
    1.52 +    actual = '';
    1.53 +    try
    1.54 +    {
    1.55 +      eval("/bar/" + flag);
    1.56 +    }
    1.57 +    catch(ex)
    1.58 +    {
    1.59 +      actual = ex + '';
    1.60 +    }
    1.61 +    reportCompare(expect, actual, summary + ': /bar/' + flag + ')');
    1.62 +  }
    1.63 +
    1.64 +  exitFunc ('test');
    1.65 +}

mercurial