|
1 // |reftest| skip -- obsolete test |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 |
|
8 /** |
|
9 Filename: string_split.js |
|
10 Description: 'Tests the split method on Strings using regular expressions' |
|
11 |
|
12 Author: Nick Lerissa |
|
13 Date: March 11, 1998 |
|
14 */ |
|
15 |
|
16 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; |
|
17 var VERSION = 'no version'; |
|
18 startTest(); |
|
19 var TITLE = 'String: split'; |
|
20 |
|
21 writeHeaderToLog('Executing script: string_split.js'); |
|
22 writeHeaderToLog( SECTION + " "+ TITLE); |
|
23 |
|
24 |
|
25 // 'a b c de f'.split(/\s/) |
|
26 new TestCase ( SECTION, "'a b c de f'.split(/\s/)", |
|
27 String(["a","b","c","de","f"]), String('a b c de f'.split(/\s/))); |
|
28 |
|
29 // 'a b c de f'.split(/\s/,3) |
|
30 new TestCase ( SECTION, "'a b c de f'.split(/\s/,3)", |
|
31 String(["a","b","c"]), String('a b c de f'.split(/\s/,3))); |
|
32 |
|
33 // 'a b c de f'.split(/X/) |
|
34 new TestCase ( SECTION, "'a b c de f'.split(/X/)", |
|
35 String(["a b c de f"]), String('a b c de f'.split(/X/))); |
|
36 |
|
37 // 'dfe23iu 34 =+65--'.split(/\d+/) |
|
38 new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(/\d+/)", |
|
39 String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(/\d+/))); |
|
40 |
|
41 // 'dfe23iu 34 =+65--'.split(new RegExp('\d+')) |
|
42 new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(new RegExp('\\d+'))", |
|
43 String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(new RegExp('\\d+')))); |
|
44 |
|
45 // 'abc'.split(/[a-z]/) |
|
46 new TestCase ( SECTION, "'abc'.split(/[a-z]/)", |
|
47 String(["","",""]), String('abc'.split(/[a-z]/))); |
|
48 |
|
49 // 'abc'.split(/[a-z]/) |
|
50 new TestCase ( SECTION, "'abc'.split(/[a-z]/)", |
|
51 String(["","",""]), String('abc'.split(/[a-z]/))); |
|
52 |
|
53 // 'abc'.split(new RegExp('[a-z]')) |
|
54 new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))", |
|
55 String(["","",""]), String('abc'.split(new RegExp('[a-z]')))); |
|
56 |
|
57 // 'abc'.split(new RegExp('[a-z]')) |
|
58 new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))", |
|
59 String(["","",""]), String('abc'.split(new RegExp('[a-z]')))); |
|
60 |
|
61 test(); |