rhino1.7.7.testsrc.tests.js1_2.regexp.global.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
gTestfile = 'global.js';
/**
Filename: global.js
Description: 'Tests RegExp attribute global'
Author: Nick Lerissa
Date: March 13, 1998
*/
var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
var VERSION = 'no version';
startTest();
var TITLE = 'RegExp: global';
writeHeaderToLog('Executing script: global.js');
writeHeaderToLog( SECTION + " "+ TITLE);
// /xyz/g.global
new TestCase ( SECTION, "/xyz/g.global",
true, /xyz/g.global);
// /xyz/.global
new TestCase ( SECTION, "/xyz/.global",
false, /xyz/.global);
// '123 456 789'.match(/\d+/g)
new TestCase ( SECTION, "'123 456 789'.match(/\\d+/g)",
String(["123","456","789"]), String('123 456 789'.match(/\d+/g)));
// '123 456 789'.match(/(\d+)/g)
new TestCase ( SECTION, "'123 456 789'.match(/(\\d+)/g)",
String(["123","456","789"]), String('123 456 789'.match(/(\d+)/g)));
// '123 456 789'.match(/\d+/)
new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)",
String(["123"]), String('123 456 789'.match(/\d+/)));
// (new RegExp('[a-z]','g')).global
new TestCase ( SECTION, "(new RegExp('[a-z]','g')).global",
true, (new RegExp('[a-z]','g')).global);
// (new RegExp('[a-z]','i')).global
new TestCase ( SECTION, "(new RegExp('[a-z]','i')).global",
false, (new RegExp('[a-z]','i')).global);
// '123 456 789'.match(new RegExp('\\d+','g'))
new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','g'))",
String(["123","456","789"]), String('123 456 789'.match(new RegExp('\\d+','g'))));
// '123 456 789'.match(new RegExp('(\\d+)','g'))
new TestCase ( SECTION, "'123 456 789'.match(new RegExp('(\\\\d+)','g'))",
String(["123","456","789"]), String('123 456 789'.match(new RegExp('(\\d+)','g'))));
// '123 456 789'.match(new RegExp('\\d+','i'))
new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','i'))",
String(["123"]), String('123 456 789'.match(new RegExp('\\d+','i'))));
test();
© 2015 - 2024 Weber Informatics LLC | Privacy Policy