1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_2/regexp/hexadecimal.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 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 +/** 1.11 + Filename: hexadecimal.js 1.12 + Description: 'Tests regular expressions containing \<number> ' 1.13 + 1.14 + Author: Nick Lerissa 1.15 + Date: March 10, 1998 1.16 +*/ 1.17 + 1.18 +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; 1.19 +var VERSION = 'no version'; 1.20 +startTest(); 1.21 +var TITLE = 'RegExp: \\x# (hex) '; 1.22 + 1.23 +writeHeaderToLog('Executing script: hexadecimal.js'); 1.24 +writeHeaderToLog( SECTION + " "+ TITLE); 1.25 + 1.26 +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'; 1.27 + 1.28 +var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; 1.29 + 1.30 +new TestCase ( SECTION, 1.31 + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", 1.32 + String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); 1.33 + 1.34 +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'; 1.35 + 1.36 +testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; 1.37 + 1.38 +new TestCase ( SECTION, 1.39 + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", 1.40 + String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); 1.41 + 1.42 +testPattern = '\\x20\\x21\\x22\\x23\\x24\\x25\\x26\\x27\\x28\\x29\\x2A\\x2B\\x2C\\x2D\\x2E\\x2F\\x30\\x31\\x32\\x33'; 1.43 + 1.44 +testString = "abc !\"#$%&'()*+,-./0123ZBC"; 1.45 + 1.46 +new TestCase ( SECTION, 1.47 + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", 1.48 + String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); 1.49 + 1.50 +testPattern = '\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x3B\\x3C\\x3D\\x3E\\x3F\\x40'; 1.51 + 1.52 +testString = "123456789:;<=>?@ABC"; 1.53 + 1.54 +new TestCase ( SECTION, 1.55 + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", 1.56 + String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); 1.57 + 1.58 +testPattern = '\\x7B\\x7C\\x7D\\x7E'; 1.59 + 1.60 +testString = "1234{|}~ABC"; 1.61 + 1.62 +new TestCase ( SECTION, 1.63 + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", 1.64 + String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); 1.65 + 1.66 +new TestCase ( SECTION, 1.67 + "'canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))", 1.68 + String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\x5A]+')))); 1.69 + 1.70 +new TestCase ( SECTION, 1.71 + "'canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))", 1.72 + String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+')))); 1.73 + 1.74 +new TestCase ( SECTION, 1.75 + "'canthisbeFOUND'.match(/[\\x61-\\x7A]+/)", 1.76 + String(["canthisbe"]), String('canthisbeFOUND'.match(/[\x61-\x7A]+/))); 1.77 + 1.78 +test();