1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_2/regexp/compile.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 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: compile.js 1.12 + Description: 'Tests regular expressions method compile' 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: compile'; 1.22 + 1.23 +writeHeaderToLog('Executing script: compile.js'); 1.24 +writeHeaderToLog( SECTION + " "+ TITLE); 1.25 + 1.26 +var regularExpression = new RegExp(); 1.27 + 1.28 +regularExpression.compile("[0-9]{3}x[0-9]{4}","i"); 1.29 + 1.30 +new TestCase ( SECTION, 1.31 + "(compile '[0-9]{3}x[0-9]{4}','i')", 1.32 + String(["456X7890"]), String('234X456X7890'.match(regularExpression))); 1.33 + 1.34 +new TestCase ( SECTION, 1.35 + "source of (compile '[0-9]{3}x[0-9]{4}','i')", 1.36 + "[0-9]{3}x[0-9]{4}", regularExpression.source); 1.37 + 1.38 +new TestCase ( SECTION, 1.39 + "global of (compile '[0-9]{3}x[0-9]{4}','i')", 1.40 + false, regularExpression.global); 1.41 + 1.42 +new TestCase ( SECTION, 1.43 + "ignoreCase of (compile '[0-9]{3}x[0-9]{4}','i')", 1.44 + true, regularExpression.ignoreCase); 1.45 + 1.46 +regularExpression.compile("[0-9]{3}X[0-9]{3}","g"); 1.47 + 1.48 +new TestCase ( SECTION, 1.49 + "(compile '[0-9]{3}X[0-9]{3}','g')", 1.50 + String(["234X456"]), String('234X456X7890'.match(regularExpression))); 1.51 + 1.52 +new TestCase ( SECTION, 1.53 + "source of (compile '[0-9]{3}X[0-9]{3}','g')", 1.54 + "[0-9]{3}X[0-9]{3}", regularExpression.source); 1.55 + 1.56 +new TestCase ( SECTION, 1.57 + "global of (compile '[0-9]{3}X[0-9]{3}','g')", 1.58 + true, regularExpression.global); 1.59 + 1.60 +new TestCase ( SECTION, 1.61 + "ignoreCase of (compile '[0-9]{3}X[0-9]{3}','g')", 1.62 + false, regularExpression.ignoreCase); 1.63 + 1.64 + 1.65 +test();