Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/hexadecimal.js

raw symbols SCIP
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 gTestfile = 'hexadecimal.js';
7
8 /**
9 Filename: hexadecimal.js
10 Description: 'Tests regular expressions containing \<number> '
11
12 Author: Nick Lerissa
13 Date: March 10, 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 = 'RegExp: \x# (hex) ';
20
21 writeHeaderToLog('Executing script: hexadecimal.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 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';
25
26 var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890";
27
28 new TestCase ( SECTION,
29 "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
30 String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern))));
31
32 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';
33
34 testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890";
35
36 new TestCase ( SECTION,
37 "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
38 String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern))));
39
40 testPattern = '\\x20\\x21\\x22\\x23\\x24\\x25\\x26\\x27\\x28\\x29\\x2A\\x2B\\x2C\\x2D\\x2E\\x2F\\x30\\x31\\x32\\x33';
41
42 testString = "abc !\"#$%&'()*+,-./0123ZBC";
43
44 new TestCase ( SECTION,
45 "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
46 String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern))));
47
48 testPattern = '\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x3B\\x3C\\x3D\\x3E\\x3F\\x40';
49
50 testString = "123456789:;<=>?@ABC";
51
52 new TestCase ( SECTION,
53 "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
54 String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern))));
55
56 testPattern = '\\x7B\\x7C\\x7D\\x7E';
57
58 testString = "1234{|}~ABC";
59
60 new TestCase ( SECTION,
61 "'" + testString + "'.match(new RegExp('" + testPattern + "'))",
62 String(["{|}~"]), String(testString.match(new RegExp(testPattern))));
63
64 new TestCase ( SECTION,
65 "'canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))",
66 String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))));
67
68 new TestCase ( SECTION,
69 "'canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))",
70 String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))));
71
72 new TestCase ( SECTION,
73 "'canthisbeFOUND'.match(/[\\x61-\\x7A]+/)",
74 String(["canthisbe"]), String('canthisbeFOUND'.match(/[\x61-\x7A]+/)));
75
76 test();