Migrated test block 19 to Dart 2.0.

BUG=
R=rnystrom@google.com

Review-Url: https://codereview.chromium.org/2985233002 .
This commit is contained in:
Ben Konyi 2017-07-31 09:49:04 -07:00
parent 401c812356
commit 011c9b0f75
53 changed files with 45 additions and 1278 deletions

View file

@ -240,15 +240,6 @@ queue_iterator_test: Crash
queue_last_test: Crash
queue_single_test: Crash
queue_test: Crash
range_error_test: Crash
reg_exp4_test: Crash
reg_exp5_test: Crash
reg_exp_all_matches_test: Crash
reg_exp_start_end_test: Crash
regexp/ascii-regexp-subject_test: Crash
regexp/bol-with-multiline_test: Crash
regexp/capture-3_test: Crash
regexp/capture_test: Crash
regexp/compile-crash_test: Crash
regexp/compile_test: Crash
regexp/early-acid3-86_test: Crash
@ -309,10 +300,6 @@ symbol_reserved_word_test/07: MissingCompileTimeError
symbol_reserved_word_test/09: Crash
symbol_reserved_word_test/10: MissingCompileTimeError
symbol_reserved_word_test/12: Crash
symbol_test/01: Crash
symbol_test/02: Crash
symbol_test/03: Crash
symbol_test/none: Crash
[ $compiler == dart2js && $dart2js_with_kernel && $host_checked ]
list_sort_test: Crash
@ -409,11 +396,17 @@ regexp/default_arguments_test: Crash
regexp/dotstar_test: Crash
regexp/extended-characters-match_test: Crash
regexp/find-first-asserted_test: Crash
regexp/look-ahead_test: Crash
regexp/malformed-escapes_test: Crash
regexp/many-brackets_test: Crash
regexp/non-bmp_test: Crash
regexp/non-capturing-backtracking_test: Crash
regexp/non-character_test: Crash
regexp/non-greedy-parentheses_test: Crash
regexp/norepeat_test: Crash
regexp/overflow_test: Crash
regexp/stack-overflow2_test: Crash
regexp/stack-overflow_test: Crash
regexp/zero-length-alternatives_test: Crash
regress_11099_test: Crash
regress_r21715_test: Crash
safe_to_string_test: Crash

View file

@ -63,6 +63,13 @@ regexp/non-capturing-groups_test: RuntimeError # Issue 29921
regexp/non-character_test: RuntimeError # Issue 29921
regexp/non-greedy-parentheses_test: RuntimeError # Issue 29921
regexp/pcre-test-4_test: RuntimeError # Issue 29921
regexp/alternative-length-miscalculation_test: RuntimeError # Issue 29921
regexp/ascii-regexp-subject_test: RuntimeError # Issue 29921
regexp/bol-with-multiline_test: RuntimeError # Issue 29921
regexp/capture-3_test: RuntimeError # Issue 29921
regexp/char-insensitive_test: RuntimeError # Issue 29921
regexp/character-match-out-of-order_test: RuntimeError # Issue 29921
regexp/loop-capture_test: RuntimeError # Issue 29921
regexp/quantified-assertions_test: RuntimeError # Issue 29921
regexp/range-bound-ffff_test: RuntimeError # Issue 29921
regexp/range-out-of-order_test: RuntimeError # Issue 29921
@ -315,6 +322,18 @@ regexp/no-extensions_test: Crash
regexp/non-capturing-groups_test: Crash
regexp/parentheses_test: Crash
regexp/pcre-test-4_test: Crash
range_error_test: Crash
reg_exp4_test: Crash
reg_exp5_test: Crash
reg_exp_all_matches_test: Crash
reg_exp_start_end_test: Crash
regexp/ascii-regexp-subject_test: Crash
regexp/capture-3_test: Crash
regexp/capture_test: Crash
symbol_test/01: Crash
symbol_test/02: Crash
symbol_test/03: Crash
symbol_test/none: Crash
regexp/range-out-of-order_test: Crash
regexp/regexp_kde_test: Crash
regexp/regexp_test: Crash
@ -459,6 +478,25 @@ regexp/non-greedy-parentheses_test: Crash
regexp/norepeat_test: Crash
regexp/overflow_test: Crash
regexp/stack-overflow_test: Crash
reg_exp1_test: Crash
reg_exp_first_match_test: Crash
reg_exp_group_test: Crash
reg_exp_groups_test: Crash
reg_exp_has_match_test: Crash
reg_exp_pattern_test: Crash
reg_exp_string_match_test: Crash
regexp/UC16_test: Crash
regexp/alternative-length-miscalculation_test: Crash
regexp/alternatives_test: Crash
regexp/assertion_test: Crash
regexp/backreferences_test: Crash
regexp/bol-with-multiline_test: Crash
regexp/bol_test: Crash
regexp/captures_test: Crash
regexp/char-insensitive_test: Crash
regexp/character-match-out-of-order_test: Crash
regexp/loop-capture_test: Crash
regexp/zero-length-alternatives_test: Crash
regexp/quantified-assertions_test: Crash
regexp/range-bound-ffff_test: Crash
regexp/ranges-and-escaped-hyphens_test: Crash

View file

@ -56,11 +56,6 @@ main_test: RuntimeError # Issue 29921
map_keys2_test: RuntimeError # Issue 29921
nan_infinity_test/01: RuntimeError # Issue 29921
null_nosuchmethod_test: RuntimeError # Issue 29921
regexp/alternative-length-miscalculation_test: RuntimeError # Issue 29921
regexp/ascii-regexp-subject_test: RuntimeError # Issue 29921
regexp/capture-3_test: RuntimeError # Issue 29921
regexp/char-insensitive_test: RuntimeError # Issue 29921
regexp/character-match-out-of-order_test: RuntimeError # Issue 29921
regexp/compile-crash_test: RuntimeError # Issue 29921
regexp/default_arguments_test: RuntimeError # Issue 29921
regexp/early-acid3-86_test: RuntimeError # Issue 29921

View file

@ -1,94 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test for testing out of range exceptions on arrays, and the content
// of range_error toString().
void main() {
testRead();
testWrite();
testToString();
}
void testRead() {
testListRead([], 0);
testListRead([], -1);
testListRead([], 1);
var list = [1];
testListRead(list, -1);
testListRead(list, 1);
list = new List(1);
testListRead(list, -1);
testListRead(list, 1);
list = new List();
testListRead(list, -1);
testListRead(list, 0);
testListRead(list, 1);
}
void testWrite() {
testListWrite([], 0);
testListWrite([], -1);
testListWrite([], 1);
var list = [1];
testListWrite(list, -1);
testListWrite(list, 1);
list = new List(1);
testListWrite(list, -1);
testListWrite(list, 1);
list = new List();
testListWrite(list, -1);
testListWrite(list, 0);
testListWrite(list, 1);
}
void testToString() {
for (var name in [null, "THENAME"]) {
for (var message in [null, "THEMESSAGE"]) {
var value = 37;
for (var re in [
new ArgumentError.value(value, name, message),
new RangeError.value(value, name, message),
new RangeError.index(value, [], name, message),
new RangeError.range(value, 0, 24, name, message)
]) {
var str = re.toString();
if (name != null) Expect.isTrue(str.contains(name), "$name in $str");
if (message != null)
Expect.isTrue(str.contains(message), "$message in $str");
Expect.isTrue(str.contains("$value"), "$value in $str");
// No empty ':' separated parts - in that case the colon is omitted too.
Expect.isFalse(str.contains(new RegExp(":\s*:")));
}
}
}
}
void testListRead(list, index) {
var exception = null;
try {
var e = list[index];
} on RangeError catch (e) {
exception = e;
}
Expect.equals(true, exception != null);
}
void testListWrite(list, index) {
var exception = null;
try {
list[index] = null;
} on RangeError catch (e) {
exception = e;
}
Expect.equals(true, exception != null);
}

View file

@ -1,31 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
import "package:expect/expect.dart";
class RegExp1Test {
static testMain() {
RegExp exp1 = new RegExp("bar|foo");
Expect.equals(true, exp1.hasMatch("foo"));
Expect.equals(true, exp1.hasMatch("bar"));
Expect.equals(false, exp1.hasMatch("gim"));
Expect.equals(true, exp1.hasMatch("just foo"));
Expect.equals("bar|foo", exp1.pattern);
Expect.equals(false, exp1.isMultiLine);
Expect.equals(true, exp1.isCaseSensitive);
RegExp exp2 = new RegExp("o+", caseSensitive: false);
Expect.equals(true, exp2.hasMatch("this looks good"));
Expect.equals(true, exp2.hasMatch("fOO"));
Expect.equals(false, exp2.hasMatch("bar"));
Expect.equals("o+", exp2.pattern);
Expect.equals(false, exp2.isCaseSensitive);
Expect.equals(false, exp2.isMultiLine);
}
}
main() {
RegExp1Test.testMain();
}

View file

@ -1,49 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
import "package:expect/expect.dart";
main() {
try {
RegExp ex = new RegExp(null);
Expect.fail("Expected: ArgumentError got: no exception");
} catch (ex) {
if (!(ex is ArgumentError)) {
Expect.fail("Expected: ArgumentError got: ${ex}");
}
}
try {
new RegExp(r"^\w+$").hasMatch(null);
Expect.fail("Expected: ArgumentError got: no exception");
} catch (ex) {
if (!(ex is ArgumentError)) {
Expect.fail("Expected: ArgumentError got: ${ex}");
}
}
try {
new RegExp(r"^\w+$").firstMatch(null);
Expect.fail("Expected: ArgumentError got: no exception");
} catch (ex) {
if (!(ex is ArgumentError)) {
Expect.fail("Expected: ArgumentError got: ${ex}");
}
}
try {
new RegExp(r"^\w+$").allMatches(null);
Expect.fail("Expected: ArgumentError got: no exception");
} catch (ex) {
if (!(ex is ArgumentError)) {
Expect.fail("Expected: ArgumentError got: ${ex}");
}
}
try {
new RegExp(r"^\w+$").stringMatch(null);
Expect.fail("Expected: ArgumentError got: no exception");
} catch (ex) {
if (!(ex is ArgumentError)) {
Expect.fail("Expected: ArgumentError got: ${ex}");
}
}
}

View file

@ -1,25 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
import "package:expect/expect.dart";
main() {
String str = "";
try {
RegExp ex = new RegExp(str);
} catch (e) {
if (!(e is ArgumentError)) {
Expect.fail("Expected: ArgumentError got: ${e}");
}
}
Expect.isFalse(new RegExp(r"^\w+$").hasMatch(str));
Match fm = new RegExp(r"^\w+$").firstMatch(str);
Expect.equals(null, fm);
Iterable<Match> am = new RegExp(r"^\w+$").allMatches(str);
Expect.isFalse(am.iterator.moveNext());
Expect.equals(null, new RegExp(r"^\w+$").stringMatch(str));
}

View file

@ -1,118 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for RegExp.allMatches.
class RegExpAllMatchesTest {
static testIterator() {
var matches = new RegExp("foo").allMatches("foo foo");
Iterator it = matches.iterator;
Expect.isTrue(it.moveNext());
Expect.equals('foo', it.current.group(0));
Expect.isTrue(it.moveNext());
Expect.equals('foo', it.current.group(0));
Expect.isFalse(it.moveNext());
// Run two iterators over the same results.
it = matches.iterator;
Iterator it2 = matches.iterator;
Expect.isTrue(it.moveNext());
Expect.isTrue(it2.moveNext());
Expect.equals('foo', it.current.group(0));
Expect.equals('foo', it2.current.group(0));
Expect.isTrue(it.moveNext());
Expect.isTrue(it2.moveNext());
Expect.equals('foo', it.current.group(0));
Expect.equals('foo', it2.current.group(0));
Expect.equals(false, it.moveNext());
Expect.equals(false, it2.moveNext());
}
static testForEach() {
var matches = new RegExp("foo").allMatches("foo foo");
var strbuf = new StringBuffer();
matches.forEach((Match m) {
strbuf.write(m.group(0));
});
Expect.equals("foofoo", strbuf.toString());
}
static testMap() {
var matches = new RegExp("foo?").allMatches("foo fo foo fo");
var mapped = matches.map((Match m) => "${m.group(0)}bar");
Expect.equals(4, mapped.length);
var strbuf = new StringBuffer();
for (String s in mapped) {
strbuf.write(s);
}
Expect.equals("foobarfobarfoobarfobar", strbuf.toString());
}
static testFilter() {
var matches = new RegExp("foo?").allMatches("foo fo foo fo");
var filtered = matches.where((Match m) {
return m.group(0) == 'foo';
});
Expect.equals(2, filtered.length);
var strbuf = new StringBuffer();
for (Match m in filtered) {
strbuf.write(m.group(0));
}
Expect.equals("foofoo", strbuf.toString());
}
static testEvery() {
var matches = new RegExp("foo?").allMatches("foo fo foo fo");
Expect.equals(true, matches.every((Match m) {
return m.group(0).startsWith("fo");
}));
Expect.equals(false, matches.every((Match m) {
return m.group(0).startsWith("foo");
}));
}
static testSome() {
var matches = new RegExp("foo?").allMatches("foo fo foo fo");
Expect.equals(true, matches.any((Match m) {
return m.group(0).startsWith("fo");
}));
Expect.equals(true, matches.any((Match m) {
return m.group(0).startsWith("foo");
}));
Expect.equals(false, matches.any((Match m) {
return m.group(0).startsWith("fooo");
}));
}
static testIsEmpty() {
var matches = new RegExp("foo?").allMatches("foo fo foo fo");
Expect.equals(false, matches.isEmpty);
matches = new RegExp("fooo").allMatches("foo fo foo fo");
Expect.equals(true, matches.isEmpty);
}
static testGetCount() {
var matches = new RegExp("foo?").allMatches("foo fo foo fo");
Expect.equals(4, matches.length);
matches = new RegExp("fooo").allMatches("foo fo foo fo");
Expect.equals(0, matches.length);
}
static testMain() {
testIterator();
testForEach();
testMap();
testFilter();
testEvery();
testSome();
testIsEmpty();
testGetCount();
}
}
main() {
RegExpAllMatchesTest.testMain();
}

View file

@ -1,18 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for RegExp.firstMatch.
class RegExpFirstMatchTest {
static testMain() {
Expect.equals('cat', new RegExp("(\\w+)").firstMatch("cat dog")[0]);
Expect.equals(null, new RegExp("foo").firstMatch("bar"));
}
}
main() {
RegExpFirstMatchTest.testMain();
}

View file

@ -1,22 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for RegExp.group.
class RegExpGroupTest {
static testMain() {
var match = new RegExp("(a(b)((c|de)+))").firstMatch("abcde");
Expect.equals('abcde', match.group(0));
Expect.equals('abcde', match.group(1));
Expect.equals('b', match.group(2));
Expect.equals('cde', match[3]);
Expect.equals('de', match[4]);
}
}
main() {
RegExpGroupTest.testMain();
}

View file

@ -1,22 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for RegExp.groups.
class RegExpGroupsTest {
static testMain() {
var match = new RegExp("(a(b)((c|de)+))").firstMatch("abcde");
var groups = match.groups([0, 4, 2, 3]);
Expect.equals('abcde', groups[0]);
Expect.equals('de', groups[1]);
Expect.equals('b', groups[2]);
Expect.equals('cde', groups[3]);
}
}
main() {
RegExpGroupsTest.testMain();
}

View file

@ -1,19 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for RegExp.hasMatch.
class RegExpHasMatchTest {
static testMain() {
Expect.equals(false, new RegExp("bar").hasMatch("foo"));
Expect.equals(true, new RegExp("bar|foo").hasMatch("foo"));
Expect.equals(true, new RegExp("o+").hasMatch("foo"));
}
}
main() {
RegExpHasMatchTest.testMain();
}

View file

@ -1,27 +0,0 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
import "package:expect/expect.dart";
// Regression test for http://dartbug.com/17998
main() {
for (var s in [
r"a",
r"a|b",
r"(?:)",
r"^",
r"$",
r"^$",
r"$^",
r"",
r"\\",
r"/",
r"[^]",
"\x00",
]) {
Expect.equals(s, new RegExp(s).pattern);
}
}

View file

@ -1,19 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
var matches = new RegExp("(a(b)((c|de)+))").allMatches("abcde abcde abcde");
var it = matches.iterator;
int start = 0;
int end = 5;
while (it.moveNext()) {
Match match = it.current;
Expect.equals(start, match.start);
Expect.equals(end, match.end);
start += 6;
end += 6;
}
}

View file

@ -1,18 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for RegExp.stringMatch.
class RegExpStringMatchTest {
static testMain() {
Expect.equals('cat', new RegExp("(\\w+)").stringMatch("cat dog"));
Expect.equals(null, new RegExp("foo").stringMatch("bar"));
}
}
main() {
RegExpStringMatchTest.testMain();
}

View file

@ -1,71 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
// UC16
// Characters used:
// "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda,
// lambda
shouldBe(
new RegExp(r"x(.)\1x", caseSensitive: false).firstMatch("x\u03a3\u03c3x"),
["x\u03a3\u03c3x", "\u03a3"],
"backref-UC16");
assertFalse(
new RegExp(r"x(...)\1", caseSensitive: false)
.hasMatch("x\u03a3\u03c2\u03c3\u03c2\u03c3"),
"\1 ASCII, string short");
assertTrue(
new RegExp(r"\u03a3((?:))\1\1x", caseSensitive: false)
.hasMatch("\u03c2x"),
"backref-UC16-empty");
assertTrue(
new RegExp(r"x(?:...|(...))\1x", caseSensitive: false)
.hasMatch("x\u03a3\u03c2\u03c3x"),
"backref-UC16-uncaptured");
assertTrue(
new RegExp(r"x(?:...|(...))\1x", caseSensitive: false)
.hasMatch("x\u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"),
"backref-UC16-backtrack");
var longUC16String =
"x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb";
shouldBe(
new RegExp(r"x(...)\1\1", caseSensitive: false)
.firstMatch(longUC16String),
[longUC16String, longUC16String.substring(1, 4)],
"backref-UC16-twice");
assertFalse(new RegExp(r"\xc1", caseSensitive: false).hasMatch('fooA'),
"quickcheck-uc16-pattern-ascii-subject");
assertFalse(new RegExp(r"[\xe9]").hasMatch('i'),
"charclass-uc16-pattern-ascii-subject");
assertFalse(new RegExp(r"\u5e74|\u6708").hasMatch('t'),
"alternation-uc16-pattern-ascii-subject");
}

View file

@ -1,37 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
description(
"This page tests for length miscalculations in regular expression processing.");
var re = new RegExp(r"b|[^b]");
assertEquals('a'.indexOf(re, 1), -1);
var re2 = new RegExp(r"[^a]|ab");
shouldBeFalse(re2.hasMatch(''));
}

View file

@ -1,52 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
description('Test regular expression processing with alternatives.');
var s1 = "<p>content</p>";
shouldBe(firstMatch(s1, new RegExp(r"<((\\/([^>]+)>)|(([^>]+)>))")),
["<p>", "p>", null, null, "p>", "p"]);
shouldBe(firstMatch(s1, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|(([^>]+)>))")),
["<p>", "p>", null, null, null, "p>", "p"]);
shouldBe(firstMatch(s1, new RegExp(r"<(a|\\/p|.+?)>")), ["<p>", "p"]);
// Force YARR to use Interpreter by using iterative parentheses
shouldBe(firstMatch(s1, new RegExp(r"<((\\/([^>]+)>)|((([^>])+)>))")),
["<p>", "p>", null, null, "p>", "p", "p"]);
shouldBe(firstMatch(s1, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|((([^>])+)>))")),
["<p>", "p>", null, null, null, "p>", "p", "p"]);
shouldBe(firstMatch(s1, new RegExp(r"<(a|\\/p|(.)+?)>")), ["<p>", "p", "p"]);
// Force YARR to use Interpreter by using backreference
var s2 = "<p>p</p>";
shouldBe(firstMatch(s2, new RegExp(r"<((\\/([^>]+)>)|(([^>]+)>))\5")),
["<p>p", "p>", null, null, "p>", "p"]);
shouldBe(firstMatch(s2, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|(([^>]+)>))\6")),
["<p>p", "p>", null, null, null, "p>", "p"]);
shouldBe(firstMatch(s2, new RegExp(r"<(a|\\/p|.+?)>\1")), ["<p>p", "p"]);
}

View file

@ -1,54 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/**
* @fileoverview Check that an initial ^ will result in a faster match fail.
*/
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
var s = "foo";
var i;
for (i = 0; i < 18; i++) {
s = s + s;
}
dynamic repeatRegexp(re) {
for (i = 0; i < 1000; i++) {
re.hasMatch(s);
}
}
repeatRegexp(new RegExp(r"^bar"));
repeatRegexp(new RegExp(r"^foo|^bar|^baz"));
repeatRegexp(new RegExp(r"(^bar)"));
repeatRegexp(new RegExp(r"(?=^bar)\w+"));
}

View file

@ -1,117 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
description("This page tests handling of parenthetical assertions.");
var regex1 = new RegExp(r"(x)(?=\1)x");
shouldBe(regex1.firstMatch('xx'), ['xx', 'x']);
var regex2 = new RegExp(r"(.*?)a(?!(a+)b\2c)\2(.*)");
shouldBe(regex2.firstMatch('baaabaac'), ['baaabaac', 'ba', null, 'abaac']);
var regex3 = new RegExp(r"(?=(a+?))(\1ab)");
shouldBe(regex3.firstMatch('aaab'), ['aab', 'a', 'aab']);
var regex4 = new RegExp(r"(?=(a+?))(\1ab)");
shouldBe(regex4.firstMatch('aaab'), ['aab', 'a', 'aab']);
var regex5 = new RegExp(r"^P([1-6])(?=\1)([1-6])$");
shouldBe(regex5.firstMatch('P11'), ['P11', '1', '1']);
var regex6 = new RegExp(r"(([a-c])b*?\2)*");
shouldBe(regex6.firstMatch('ababbbcbc'), ['ababb', 'bb', 'b']);
var regex7 = new RegExp(r"(x)(?=x)x");
shouldBe(regex7.firstMatch('xx'), ['xx', 'x']);
var regex8 = new RegExp(r"(x)(\1)");
shouldBe(regex8.firstMatch('xx'), ['xx', 'x', 'x']);
var regex9 = new RegExp(r"(x)(?=\1)x");
shouldBeNull(regex9.firstMatch('xy'));
var regex10 = new RegExp(r"(x)(?=x)x");
shouldBeNull(regex10.firstMatch('xy'));
var regex11 = new RegExp(r"(x)(\1)");
shouldBeNull(regex11.firstMatch('xy'));
var regex12 = new RegExp(r"(x)(?=\1)x");
shouldBeNull(regex12.firstMatch('x'));
shouldBe(regex12.firstMatch('xx'), ['xx', 'x']);
shouldBe(regex12.firstMatch('xxy'), ['xx', 'x']);
var regex13 = new RegExp(r"(x)zzz(?=\1)x");
shouldBe(regex13.firstMatch('xzzzx'), ['xzzzx', 'x']);
shouldBe(regex13.firstMatch('xzzzxy'), ['xzzzx', 'x']);
var regex14 = new RegExp(r"(a)\1(?=(b*c))bc");
shouldBe(regex14.firstMatch('aabc'), ['aabc', 'a', 'bc']);
shouldBe(regex14.firstMatch('aabcx'), ['aabc', 'a', 'bc']);
var regex15 = new RegExp(r"(a)a(?=(b*c))bc");
shouldBe(regex15.firstMatch('aabc'), ['aabc', 'a', 'bc']);
shouldBe(regex15.firstMatch('aabcx'), ['aabc', 'a', 'bc']);
var regex16 = new RegExp(r"a(?=(b*c))bc");
shouldBeNull(regex16.firstMatch('ab'));
shouldBe(regex16.firstMatch('abc'), ['abc', 'bc']);
var regex17 = new RegExp(r"(?=((?:ab)*))a");
shouldBe(regex17.firstMatch('ab'), ['a', 'ab']);
shouldBe(regex17.firstMatch('abc'), ['a', 'ab']);
var regex18 = new RegExp(r"(?=((?:xx)*))x");
shouldBe(regex18.firstMatch('x'), ['x', '']);
shouldBe(regex18.firstMatch('xx'), ['x', 'xx']);
shouldBe(regex18.firstMatch('xxx'), ['x', 'xx']);
var regex19 = new RegExp(r"(?=((xx)*))x");
shouldBe(regex19.firstMatch('x'), ['x', '', null]);
shouldBe(regex19.firstMatch('xx'), ['x', 'xx', 'xx']);
shouldBe(regex19.firstMatch('xxx'), ['x', 'xx', 'xx']);
var regex20 = new RegExp(r"(?=(xx))+x");
shouldBeNull(regex20.firstMatch('x'));
shouldBe(regex20.firstMatch('xx'), ['x', 'xx']);
shouldBe(regex20.firstMatch('xxx'), ['x', 'xx']);
var regex21 = new RegExp(r"(?=a+b)aab");
shouldBe(regex21.firstMatch('aab'), ['aab']);
var regex22 = new RegExp(
r"(?!(u|m{0,}g+)u{1,}|2{2,}!1%n|(?!K|(?=y)|(?=ip))+?)(?=(?=(((?:7))*?)*?))p",
multiLine: true);
shouldBeNull(regex22.firstMatch('55up'));
var regex23 = new RegExp(r"(?=(a)b|c?)()*d");
shouldBeNull(regex23.firstMatch('ax'));
var regex24 = new RegExp(r"(?=a|b?)c");
shouldBeNull(regex24.firstMatch('x'));
}

View file

@ -1,47 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
description(
"Test to ensure correct behaviour when using backreferences in a RegExp");
shouldBeTrue(new RegExp(r"(...)\1$").hasMatch('abcabc'));
shouldBeFalse(new RegExp(r"(...)\1$").hasMatch('abcdef'));
shouldBeFalse(new RegExp(r"(...)\2$").hasMatch('abcabc'));
shouldBeFalse(new RegExp(r"(...)\2$").hasMatch('abc'));
shouldBeTrue(new RegExp(r"\1(...)$").hasMatch('abcabc'));
shouldBeTrue(new RegExp(r"\1(...)$").hasMatch('abcdef'));
shouldBeFalse(new RegExp(r"\2(...)$").hasMatch('abcabc'));
shouldBeFalse(new RegExp(r"\2(...)$").hasMatch('abc'));
shouldBeTrue(new RegExp(r"\1?(...)$").hasMatch('abc'));
shouldBeTrue(new RegExp(r"\1?(...)$").hasMatch('abc'));
var re = new RegExp(r"[^b]*((..)|(\2))+Sz", caseSensitive: false);
shouldBeFalse(re.hasMatch('axabcd'));
shouldBeTrue(re.hasMatch('axabcsz'));
}

View file

@ -1,40 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
description(
'Test for beginning of line (BOL or ^) matching in a multiline string</a>');
var s = "aced\nabc";
shouldBeNull(firstMatch(s, new RegExp(r"^abc")));
shouldBe(firstMatch(s, new RegExp(r"^abc", multiLine: true)), ["abc"]);
shouldBeNull(firstMatch(s, new RegExp(r"(^|X)abc")));
shouldBe(
firstMatch(s, new RegExp(r"(^|X)abc", multiLine: true)), ["abc", ""]);
shouldBe(
firstMatch(s, new RegExp(r"(^a|Xa)bc", multiLine: true)), ["abc", "a"]);
}

View file

@ -1,54 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
description('Test for beginning of line (BOL or ^) matching</a>');
var s = "abc123def456xyzabc789abc999";
shouldBeNull(firstMatch(s, new RegExp(r"^notHere")));
shouldBe(firstMatch(s, new RegExp(r"^abc")), ["abc"]);
shouldBe(firstMatch(s, new RegExp(r"(^|X)abc")), ["abc", ""]);
shouldBe(firstMatch(s, new RegExp(r"^longer|123")), ["123"]);
shouldBe(firstMatch(s, new RegExp(r"(^abc|c)123")), ["abc123", "abc"]);
shouldBe(firstMatch(s, new RegExp(r"(c|^abc)123")), ["abc123", "abc"]);
shouldBe(firstMatch(s, new RegExp(r"(^ab|abc)123")), ["abc123", "abc"]);
shouldBe(firstMatch(s, new RegExp(r"(bc|^abc)([0-9]*)a")),
["bc789a", "bc", "789"]);
shouldBeNull(new RegExp(r"(?:(Y)X)|(X)").firstMatch("abc"));
shouldBeNull(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abc"));
shouldBeNull(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcd"));
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("Xabcd"), ["X", null]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("aXbcd"), ["X", "X"]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abXcd"), ["X", "X"]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcXd"), ["X", "X"]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcdX"), ["X", "X"]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("YXabcd"), ["YX", null]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("aYXbcd"), ["YX", null]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abYXcd"), ["YX", null]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcYXd"), ["YX", null]);
shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcdYX"), ["YX", null]);
}

View file

@ -1,130 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
dynamic oneMatch(re) {
assertEquals("acd", "abcd".replaceAll(re, ""));
}
oneMatch(new RegExp(r"b"));
oneMatch(new RegExp(r"b"));
assertEquals("acdacd", "abcdabcd".replaceAll(new RegExp(r"b"), ""));
dynamic captureMatch(re) {
var match = firstMatch("abcd", re);
assertEquals("b", match.group(1));
assertEquals("c", match.group(2));
}
captureMatch(new RegExp(r"(b)(c)"));
captureMatch(new RegExp(r"(b)(c)"));
// A test that initially does a zero width match, but later does a non-zero
// width match.
var a = "foo bar baz".replaceAll(new RegExp(r"^|bar"), "");
assertEquals("foo baz", a);
a = "foo bar baz".replaceAll(new RegExp(r"^|bar"), "*");
assertEquals("*foo * baz", a);
// We test FilterASCII using regexps that will backtrack forever. Since
// a regexp with a non-ASCII character in it can never match an ASCII
// string we can test that the relevant node is removed by verifying that
// there is no hang.
dynamic NoHang(re) {
firstMatch("This is an ASCII string that could take forever", re);
}
NoHang(new RegExp(
r"(((.*)*)*x)Ā")); // Continuation after loop is filtered, so is loop.
NoHang(new RegExp(r"(((.*)*)*Ā)foo")); // Body of loop filtered.
NoHang(new RegExp(
r"Ā(((.*)*)*x)")); // Everything after a filtered character is filtered.
NoHang(new RegExp(
r"(((.*)*)*x)Ā")); // Everything before a filtered character is filtered.
NoHang(new RegExp(
r"[ćăĀ](((.*)*)*x)")); // Everything after a filtered class is filtered.
NoHang(new RegExp(
r"(((.*)*)*x)[ćăĀ]")); // Everything before a filtered class is filtered.
NoHang(new RegExp(r"[^\x00-\xff](((.*)*)*x)")); // After negated class.
NoHang(new RegExp(r"(((.*)*)*x)[^\x00-\xff]")); // Before negated class.
NoHang(new RegExp(r"(?!(((.*)*)*x)Ā)foo")); // Negative lookahead is filtered.
NoHang(new RegExp(
r"(?!(((.*)*)*x))Ā")); // Continuation branch of negative lookahead.
NoHang(new RegExp(r"(?=(((.*)*)*x)Ā)foo")); // Positive lookahead is filtered.
NoHang(new RegExp(
r"(?=(((.*)*)*x))Ā")); // Continuation branch of positive lookahead.
NoHang(new RegExp(
r"(?=Ā)(((.*)*)*x)")); // Positive lookahead also prunes continuation.
NoHang(new RegExp(
r"(æ|ø|Ā)(((.*)*)*x)")); // All branches of alternation are filtered.
NoHang(new RegExp(r"(a|b|(((.*)*)*x))Ā")); // 1 out of 3 branches pruned.
NoHang(new RegExp(
r"(a|(((.*)*)*x)ă|(((.*)*)*x)Ā)")); // 2 out of 3 branches pruned.
var s = "Don't prune based on a repetition of length 0";
assertEquals(null, firstMatch(s, new RegExp(r"å{1,1}prune")));
assertEquals("prune", (firstMatch(s, new RegExp(r"å{0,0}prune"))[0]));
// Some very deep regexps where FilterASCII gives up in order not to make the
// stack overflow.
var regex6 = new RegExp(r"a*\u0100*\w");
var input0 = "a";
regex6.firstMatch(input0);
var re = "\u0100*\\w";
for (var i = 0; i < 200; i++) re = "a*" + re;
var regex7 = new RegExp(re);
regex7.firstMatch(input0);
var regex8 = new RegExp(re, caseSensitive: false);
regex8.firstMatch(input0);
re = "[\u0100]*\\w";
for (var i = 0; i < 200; i++) re = "a*" + re;
var regex9 = new RegExp(re);
regex9.firstMatch(input0);
var regex10 = new RegExp(re, caseSensitive: false);
regex10.firstMatch(input0);
var regex11 = new RegExp(r"^(?:[^\u0000-\u0080]|[0-9a-z?,.!&\s#()])+$",
caseSensitive: false);
regex11.firstMatch(input0);
var regex12 = new RegExp(
r"u(\xf0{8}?\D*?|( ? !)$h??(|)*?(||)+?\6((?:\W\B|--\d-*-|)?$){0, }?|^Y( ? !1)\d+)+a");
regex12.firstMatch("");
}

View file

@ -1,57 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
// Tests from http://blog.stevenlevithan.com/archives/npcg-javascript
assertEquals(true, new RegExp(r"(x)?\1y").hasMatch("y"));
shouldBe(new RegExp(r"(x)?\1y").firstMatch("y"), ["y", null]);
shouldBe(new RegExp(r"(x)?y").firstMatch("y"), ["y", null]);
shouldBe(firstMatch("y", new RegExp(r"(x)?\1y")), ["y", null]);
shouldBe(firstMatch("y", new RegExp(r"(x)?y")), ["y", null]);
shouldBe(firstMatch("y", new RegExp(r"(x)?\1y")), ["y", null]);
Expect.listEquals(["", ""], "y".split(new RegExp(r"(x)?\1y")));
Expect.listEquals(["", ""], "y".split(new RegExp(r"(x)?y")));
assertEquals(0, "y".indexOf(new RegExp(r"(x)?\1y")));
assertEquals("z", "y".replaceAll(new RegExp(r"(x)?\1y"), "z"));
// See https://bugzilla.mozilla.org/show_bug.cgi?id=476146
shouldBe(new RegExp(r"^(b+|a){1,2}?bc").firstMatch("bbc"), ["bbc", "b"]);
shouldBe(
new RegExp(r"((\3|b)\2(a)){2,}").firstMatch("bbaababbabaaaaabbaaaabba"),
["bbaa", "a", "", "a"]);
// From crbug.com/128821 - don't hang:
firstMatch(
"",
new RegExp(
r"((a|i|A|I|u|o|U|O)(s|c|b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|y|z|B|C|D|F|G|H|J|K|L|M|N|P|Q|R|S|T|V|W|X|Y|Z)*) de\/da([.,!?\s]|$)"));
}

View file

@ -1,37 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
var re = new RegExp(
r"^(((N({)?)|(R)|(U)|(V)|(B)|(H)|(n((n)|(r)|(v)|(h))?)|(r(r)?)|(v)|(b((n)|(b))?)|(h))|((Y)|(A)|(E)|(o(u)?)|(p(u)?)|(q(u)?)|(s)|(t)|(u)|(w)|(x(u)?)|(y)|(z)|(a((T)|(A)|(L))?)|(c)|(e)|(f(u)?)|(g(u)?)|(i)|(j)|(l)|(m(u)?)))+");
var str = "Avtnennan gunzvmu pubExnY nEvln vaTxh rmuhguhaTxnY";
assertTrue(re.hasMatch(str));
}

View file

@ -1,68 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
description(
"This test checks the case-insensitive matching of character literals.");
shouldBeTrue(new RegExp(r"\u00E5", caseSensitive: false)
.hasMatch('new RegExp(r"\u00E5")'));
shouldBeTrue(new RegExp(r"\u00E5", caseSensitive: false)
.hasMatch('new RegExp(r"\u00C5")'));
shouldBeTrue(new RegExp(r"\u00C5", caseSensitive: false)
.hasMatch('new RegExp(r"\u00E5")'));
shouldBeTrue(new RegExp(r"\u00C5", caseSensitive: false)
.hasMatch('new RegExp(r"\u00C5")'));
shouldBeFalse(new RegExp(r"\u00E5", caseSensitive: false).hasMatch('P'));
shouldBeFalse(new RegExp(r"\u00E5", caseSensitive: false).hasMatch('PASS'));
shouldBeFalse(new RegExp(r"\u00C5", caseSensitive: false).hasMatch('P'));
shouldBeFalse(new RegExp(r"\u00C5", caseSensitive: false).hasMatch('PASS'));
shouldBeNull(firstMatch('PASS', new RegExp(r"\u00C5", caseSensitive: false)));
shouldBeNull(firstMatch('PASS', new RegExp(r"\u00C5", caseSensitive: false)));
assertEquals(
'PAS\u00E5'.replaceAll(new RegExp(r"\u00E5", caseSensitive: false), 'S'),
'PASS');
assertEquals(
'PAS\u00E5'.replaceAll(new RegExp(r"\u00C5", caseSensitive: false), 'S'),
'PASS');
assertEquals(
'PAS\u00C5'.replaceAll(new RegExp(r"\u00E5", caseSensitive: false), 'S'),
'PASS');
assertEquals(
'PAS\u00C5'.replaceAll(new RegExp(r"\u00C5", caseSensitive: false), 'S'),
'PASS');
assertEquals(
'PASS'.replaceAll(new RegExp(r"\u00E5", caseSensitive: false), '%C3%A5'),
'PASS');
assertEquals(
'PASS'.replaceAll(new RegExp(r"\u00C5", caseSensitive: false), '%C3%A5'),
'PASS');
}

View file

@ -1,33 +0,0 @@
// Copyright (c) 2014, the Dart project authors. All rights reserved.
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import 'v8_regexp_utils.dart';
import 'package:expect/expect.dart';
void main() {
description(
'Test to ensure RegExp generates single character matches in the correct order');
shouldBe(new RegExp(r"[\w']+").firstMatch("'_'"), ["'_'"]);
}