michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: Filename: octal.js michael@0: Description: 'Tests regular expressions containing \ ' michael@0: michael@0: Author: Nick Lerissa michael@0: Date: March 10, 1998 michael@0: */ michael@0: michael@0: var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; michael@0: var VERSION = 'no version'; michael@0: startTest(); michael@0: var TITLE = 'RegExp: \# (octal) '; michael@0: michael@0: writeHeaderToLog('Executing script: octal.js'); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: var testPattern = '\\101\\102\\103\\104\\105\\106\\107\\110\\111\\112\\113\\114\\115\\116\\117\\120\\121\\122\\123\\124\\125\\126\\127\\130\\131\\132'; michael@0: michael@0: var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; michael@0: michael@0: new TestCase ( SECTION, michael@0: "'" + testString + "'.match(new RegExp('" + testPattern + "'))", michael@0: String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); michael@0: michael@0: testPattern = '\\141\\142\\143\\144\\145\\146\\147\\150\\151\\152\\153\\154\\155\\156\\157\\160\\161\\162\\163\\164\\165\\166\\167\\170\\171\\172'; michael@0: michael@0: testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; michael@0: michael@0: new TestCase ( SECTION, michael@0: "'" + testString + "'.match(new RegExp('" + testPattern + "'))", michael@0: String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); michael@0: michael@0: testPattern = '\\40\\41\\42\\43\\44\\45\\46\\47\\50\\51\\52\\53\\54\\55\\56\\57\\60\\61\\62\\63'; michael@0: michael@0: testString = "abc !\"#$%&'()*+,-./0123ZBC"; michael@0: michael@0: new TestCase ( SECTION, michael@0: "'" + testString + "'.match(new RegExp('" + testPattern + "'))", michael@0: String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); michael@0: michael@0: testPattern = '\\64\\65\\66\\67\\70\\71\\72\\73\\74\\75\\76\\77\\100'; michael@0: michael@0: testString = "123456789:;<=>?@ABC"; michael@0: michael@0: new TestCase ( SECTION, michael@0: "'" + testString + "'.match(new RegExp('" + testPattern + "'))", michael@0: String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); michael@0: michael@0: testPattern = '\\173\\174\\175\\176'; michael@0: michael@0: testString = "1234{|}~ABC"; michael@0: michael@0: new TestCase ( SECTION, michael@0: "'" + testString + "'.match(new RegExp('" + testPattern + "'))", michael@0: String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); michael@0: michael@0: new TestCase ( SECTION, michael@0: "'canthisbeFOUND'.match(new RegExp('[A-\\132]+'))", michael@0: String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\132]+')))); michael@0: michael@0: new TestCase ( SECTION, michael@0: "'canthisbeFOUND'.match(new RegExp('[\\141-\\172]+'))", michael@0: String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\141-\\172]+')))); michael@0: michael@0: new TestCase ( SECTION, michael@0: "'canthisbeFOUND'.match(/[\\141-\\172]+/)", michael@0: String(["canthisbe"]), String('canthisbeFOUND'.match(/[\141-\172]+/))); michael@0: michael@0: test();