|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 Filename: hexadecimal.js |
|
9 Description: 'Tests regular expressions containing \<number> ' |
|
10 |
|
11 Author: Nick Lerissa |
|
12 Date: March 10, 1998 |
|
13 */ |
|
14 |
|
15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; |
|
16 var VERSION = 'no version'; |
|
17 startTest(); |
|
18 var TITLE = 'RegExp: \\x# (hex) '; |
|
19 |
|
20 writeHeaderToLog('Executing script: hexadecimal.js'); |
|
21 writeHeaderToLog( SECTION + " "+ TITLE); |
|
22 |
|
23 var testPattern = '\\x41\\x42\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x4B\\x4C\\x4D\\x4E\\x4F\\x50\\x51\\x52\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A'; |
|
24 |
|
25 var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; |
|
26 |
|
27 new TestCase ( SECTION, |
|
28 "'" + testString + "'.match(new RegExp('" + testPattern + "'))", |
|
29 String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); |
|
30 |
|
31 testPattern = '\\x61\\x62\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x6B\\x6C\\x6D\\x6E\\x6F\\x70\\x71\\x72\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7A'; |
|
32 |
|
33 testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; |
|
34 |
|
35 new TestCase ( SECTION, |
|
36 "'" + testString + "'.match(new RegExp('" + testPattern + "'))", |
|
37 String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); |
|
38 |
|
39 testPattern = '\\x20\\x21\\x22\\x23\\x24\\x25\\x26\\x27\\x28\\x29\\x2A\\x2B\\x2C\\x2D\\x2E\\x2F\\x30\\x31\\x32\\x33'; |
|
40 |
|
41 testString = "abc !\"#$%&'()*+,-./0123ZBC"; |
|
42 |
|
43 new TestCase ( SECTION, |
|
44 "'" + testString + "'.match(new RegExp('" + testPattern + "'))", |
|
45 String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); |
|
46 |
|
47 testPattern = '\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x3B\\x3C\\x3D\\x3E\\x3F\\x40'; |
|
48 |
|
49 testString = "123456789:;<=>?@ABC"; |
|
50 |
|
51 new TestCase ( SECTION, |
|
52 "'" + testString + "'.match(new RegExp('" + testPattern + "'))", |
|
53 String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); |
|
54 |
|
55 testPattern = '\\x7B\\x7C\\x7D\\x7E'; |
|
56 |
|
57 testString = "1234{|}~ABC"; |
|
58 |
|
59 new TestCase ( SECTION, |
|
60 "'" + testString + "'.match(new RegExp('" + testPattern + "'))", |
|
61 String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); |
|
62 |
|
63 new TestCase ( SECTION, |
|
64 "'canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))", |
|
65 String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\x5A]+')))); |
|
66 |
|
67 new TestCase ( SECTION, |
|
68 "'canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))", |
|
69 String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+')))); |
|
70 |
|
71 new TestCase ( SECTION, |
|
72 "'canthisbeFOUND'.match(/[\\x61-\\x7A]+/)", |
|
73 String(["canthisbe"]), String('canthisbeFOUND'.match(/[\x61-\x7A]+/))); |
|
74 |
|
75 test(); |