| OLD | NEW |
| 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 13 matching lines...) Expand all Loading... |
| 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import 'v8_regexp_utils.dart'; | 29 import 'v8_regexp_utils.dart'; |
| 30 import 'package:expect/expect.dart'; | 30 import 'package:expect/expect.dart'; |
| 31 | 31 |
| 32 void main() { | 32 void main() { |
| 33 // Long string to trigger caching. | 33 // Long string to trigger caching. |
| 34 var string = | 34 var string = """Friends, Romans, countrymen, lend me your ears! |
| 35 """Friends, Romans, countrymen, lend me your ears! | |
| 36 I come to bury Caesar, not to praise him. | 35 I come to bury Caesar, not to praise him. |
| 37 The evil that men do lives after them, | 36 The evil that men do lives after them, |
| 38 The good is oft interred with their bones; | 37 The good is oft interred with their bones; |
| 39 So let it be with Caesar. The noble Brutus | 38 So let it be with Caesar. The noble Brutus |
| 40 Hath told you Caesar was ambitious; | 39 Hath told you Caesar was ambitious; |
| 41 If it were so, it was a grievous fault, | 40 If it were so, it was a grievous fault, |
| 42 And grievously hath Caesar answer'd it. | 41 And grievously hath Caesar answer'd it. |
| 43 Here, under leave of Brutus and the rest- | 42 Here, under leave of Brutus and the rest- |
| 44 For Brutus is an honorable man; | 43 For Brutus is an honorable man; |
| 45 So are they all, all honorable men- | 44 So are they all, all honorable men- |
| (...skipping 17 matching lines...) Expand all Loading... |
| 63 But here I am to speak what I do know. | 62 But here I am to speak what I do know. |
| 64 You all did love him once, not without cause; | 63 You all did love him once, not without cause; |
| 65 What cause withholds you then to mourn for him? | 64 What cause withholds you then to mourn for him? |
| 66 O judgement, thou art fled to brutish beasts, | 65 O judgement, thou art fled to brutish beasts, |
| 67 And men have lost their reason. Bear with me; | 66 And men have lost their reason. Bear with me; |
| 68 My heart is in the coffin there with Caesar, | 67 My heart is in the coffin there with Caesar, |
| 69 And I must pause till it come back to me."""; | 68 And I must pause till it come back to me."""; |
| 70 | 69 |
| 71 var replaced = string.replaceAll(new RegExp(r"\b\w+\b"), "foo"); | 70 var replaced = string.replaceAll(new RegExp(r"\b\w+\b"), "foo"); |
| 72 for (var i = 0; i < 3; i++) { | 71 for (var i = 0; i < 3; i++) { |
| 73 assertEquals(replaced, | 72 assertEquals(replaced, string.replaceAll(new RegExp(r"\b\w+\b"), "foo")); |
| 74 string.replaceAll(new RegExp(r"\b\w+\b"), "foo")); | |
| 75 } | 73 } |
| 76 | 74 |
| 77 // Check that the result is in a COW array. | 75 // Check that the result is in a COW array. |
| 78 var words = string.split(" "); | 76 var words = string.split(" "); |
| 79 assertEquals("Friends,", words[0]); | 77 assertEquals("Friends,", words[0]); |
| 80 words[0] = "Enemies,"; | 78 words[0] = "Enemies,"; |
| 81 words = string.split(" "); | 79 words = string.split(" "); |
| 82 assertEquals("Friends,", words[0]); | 80 assertEquals("Friends,", words[0]); |
| 83 } | 81 } |
| OLD | NEW |