js/src/tests/js1_2/regexp/string_split.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_2/regexp/string_split.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +// |reftest| skip -- obsolete test
     1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +
    1.11 +/**
    1.12 +   Filename:     string_split.js
    1.13 +   Description:  'Tests the split method on Strings using regular expressions'
    1.14 +
    1.15 +   Author:       Nick Lerissa
    1.16 +   Date:         March 11, 1998
    1.17 +*/
    1.18 +
    1.19 +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
    1.20 +var VERSION = 'no version';
    1.21 +startTest();
    1.22 +var TITLE   = 'String: split';
    1.23 +
    1.24 +writeHeaderToLog('Executing script: string_split.js');
    1.25 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.26 +
    1.27 +
    1.28 +// 'a b c de f'.split(/\s/)
    1.29 +new TestCase ( SECTION, "'a b c de f'.split(/\s/)",
    1.30 +	       String(["a","b","c","de","f"]), String('a b c de f'.split(/\s/)));
    1.31 +
    1.32 +// 'a b c de f'.split(/\s/,3)
    1.33 +new TestCase ( SECTION, "'a b c de f'.split(/\s/,3)",
    1.34 +	       String(["a","b","c"]), String('a b c de f'.split(/\s/,3)));
    1.35 +
    1.36 +// 'a b c de f'.split(/X/)
    1.37 +new TestCase ( SECTION, "'a b c de f'.split(/X/)",
    1.38 +	       String(["a b c de f"]), String('a b c de f'.split(/X/)));
    1.39 +
    1.40 +// 'dfe23iu 34 =+65--'.split(/\d+/)
    1.41 +new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(/\d+/)",
    1.42 +	       String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(/\d+/)));
    1.43 +
    1.44 +// 'dfe23iu 34 =+65--'.split(new RegExp('\d+'))
    1.45 +new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(new RegExp('\\d+'))",
    1.46 +	       String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(new RegExp('\\d+'))));
    1.47 +
    1.48 +// 'abc'.split(/[a-z]/)
    1.49 +new TestCase ( SECTION, "'abc'.split(/[a-z]/)",
    1.50 +	       String(["","",""]), String('abc'.split(/[a-z]/)));
    1.51 +
    1.52 +// 'abc'.split(/[a-z]/)
    1.53 +new TestCase ( SECTION, "'abc'.split(/[a-z]/)",
    1.54 +	       String(["","",""]), String('abc'.split(/[a-z]/)));
    1.55 +
    1.56 +// 'abc'.split(new RegExp('[a-z]'))
    1.57 +new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))",
    1.58 +	       String(["","",""]), String('abc'.split(new RegExp('[a-z]'))));
    1.59 +
    1.60 +// 'abc'.split(new RegExp('[a-z]'))
    1.61 +new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))",
    1.62 +	       String(["","",""]), String('abc'.split(new RegExp('[a-z]'))));
    1.63 +
    1.64 +test();

mercurial