Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: tests/corelib/regexp/regexp_test.dart

Issue 2510783002: VM: Optimize RegExp.matchAsPrefix(...) by generating a sticky RegExp specialization. (Closed)
Patch Set: Done Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/regexp_assembler_ir.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. All rights reserved. 1 // Copyright (c) 2014, the Dart project authors. All rights reserved.
2 // Copyright 2012 the V8 project authors. All rights reserved. 2 // Copyright 2012 the V8 project authors. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 assertThrows(() => new RegExp('(?=*)')); 584 assertThrows(() => new RegExp('(?=*)'));
585 assertThrows(() => new RegExp('(?!*)')); 585 assertThrows(() => new RegExp('(?!*)'));
586 586
587 // Test trimmed regular expression for RegExp.test(). 587 // Test trimmed regular expression for RegExp.test().
588 assertTrue("abc".contains(new RegExp(r".*abc"))); 588 assertTrue("abc".contains(new RegExp(r".*abc")));
589 assertFalse("q".contains(new RegExp(r".*\d+"))); 589 assertFalse("q".contains(new RegExp(r".*\d+")));
590 590
591 // Tests skipped from V8: 591 // Tests skipped from V8:
592 // Test that RegExp.prototype.toString() throws TypeError for 592 // Test that RegExp.prototype.toString() throws TypeError for
593 // incompatible receivers (ES5 section 15.10.6 and 15.10.6.4). 593 // incompatible receivers (ES5 section 15.10.6 and 15.10.6.4).
594
595 testSticky();
594 } 596 }
597
598 testSticky() {
599 var re = new RegExp(r"foo.bar");
600 Expect.isNotNull(re.matchAsPrefix("foo_bar", 0));
601 Expect.isNull(re.matchAsPrefix("..foo_bar", 0));
602 Expect.isNotNull(re.matchAsPrefix("..foo_bar", 2));
603
604 re = new RegExp(r"^foo");
605 Expect.isNotNull(re.matchAsPrefix("foobar", 0));
606 Expect.isNull(re.matchAsPrefix("..foo", 0));
607 Expect.isNull(re.matchAsPrefix("..foo", 2));
608
609 re = new RegExp(r"^foo", multiLine: true);
610 Expect.isNotNull(re.matchAsPrefix("foobar", 0));
611 Expect.isNull(re.matchAsPrefix("..\nfoo", 0));
612 Expect.isNotNull(re.matchAsPrefix("..\nfoo", 3));
613 Expect.isNull(re.matchAsPrefix("..\nfoofoo", 6));
614
615 re = new RegExp(r"bar$");
616 Expect.isNull(re.matchAsPrefix("foobar", 0));
617 Expect.isNotNull(re.matchAsPrefix("foobar", 3));
618 }
OLDNEW
« no previous file with comments | « runtime/vm/regexp_assembler_ir.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698