OLD | NEW |
(Empty) | |
| 1 dart_library.library('corelib/regexp/results-cache_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__results$45cache_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const results$45cache_test = Object.create(null); |
| 11 const v8_regexp_utils = Object.create(null); |
| 12 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.functionType(dart.void,
[])))(); |
| 13 let ListOfString = () => (ListOfString = dart.constFn(core.List$(core.String))
)(); |
| 14 let VoidTovoid$ = () => (VoidTovoid$ = dart.constFn(dart.definiteFunctionType(
dart.void, [])))(); |
| 15 let dynamicAnddynamic__Tovoid = () => (dynamicAnddynamic__Tovoid = dart.constF
n(dart.definiteFunctionType(dart.void, [dart.dynamic, dart.dynamic], [core.Strin
g])))(); |
| 16 let dynamic__Tovoid = () => (dynamic__Tovoid = dart.constFn(dart.definiteFunct
ionType(dart.void, [dart.dynamic], [core.String])))(); |
| 17 let dynamic__Tovoid$ = () => (dynamic__Tovoid$ = dart.constFn(dart.definiteFun
ctionType(dart.void, [dart.dynamic], [core.num])))(); |
| 18 let dynamicAnddynamicAndnumTovoid = () => (dynamicAnddynamicAndnumTovoid = dar
t.constFn(dart.definiteFunctionType(dart.void, [dart.dynamic, dart.dynamic, core
.num])))(); |
| 19 let dynamicTovoid = () => (dynamicTovoid = dart.constFn(dart.definiteFunctionT
ype(dart.void, [dart.dynamic])))(); |
| 20 let StringAndRegExpToMatch = () => (StringAndRegExpToMatch = dart.constFn(dart
.definiteFunctionType(core.Match, [core.String, core.RegExp])))(); |
| 21 let MatchToString = () => (MatchToString = dart.constFn(dart.definiteFunctionT
ype(core.String, [core.Match])))(); |
| 22 let StringAndRegExpToListOfString = () => (StringAndRegExpToListOfString = dar
t.constFn(dart.definiteFunctionType(ListOfString(), [core.String, core.RegExp]))
)(); |
| 23 results$45cache_test.main = function() { |
| 24 let string = "Friends, Romans, countrymen, lend me your ears! \n I come to
bury Caesar, not to praise him. \n The evil that men do lives after the
m, \n The good is oft interred with their bones; \n So let it
be with Caesar. The noble Brutus \n Hath told you Caesar was ambitious;
\n If it were so, it was a grievous fault, \n And grievou
sly hath Caesar answer'd it. \n Here, under leave of Brutus and the re
st- \n For Brutus is an honorable man; \n So are they
all, all honorable men- \n Come I to speak in Caesar's funeral.
\n He was my friend, faithful and just to me; \n But Brutus sa
ys he was ambitious, \n And Brutus is an honorable man.
\n He hath brought many captives home to Rome, \n Whose ransoms
did the general coffers fill. \n Did this in Caesar seem ambitious?
\n When that the poor have cried, Caesar hath wept; \n Ambition should
be made of sterner stuff: \n Yet Brutus says he was ambitious,
\n And Brutus is an honorable man. \n You all did see
that on the Lupercal \n I thrice presented him a kingly crown,
\n Which he did thrice refuse. Was this ambition? \n Yet Brutus says h
e was ambitious, \n And sure he is an honorable man.
\n I speak not to disprove what Brutus spoke, \n But here I am to s
peak what I do know. \n You all did love him once, not without cause;
\n What cause withholds you then to mourn for him? \n O judgement, thou a
rt fled to brutish beasts, \n And men have lost their reason. Bear with me;
\n My heart is in the coffin there with Caesar, \n And I must pause til
l it come back to me."; |
| 25 let replaced = string[dartx.replaceAll](core.RegExp.new("\\b\\w+\\b"), "foo"
); |
| 26 for (let i = 0; i < 3; i++) { |
| 27 v8_regexp_utils.assertEquals(replaced, string[dartx.replaceAll](core.RegEx
p.new("\\b\\w+\\b"), "foo")); |
| 28 } |
| 29 let words = string[dartx.split](" "); |
| 30 v8_regexp_utils.assertEquals("Friends,", words[dartx.get](0)); |
| 31 words[dartx.set](0, "Enemies,"); |
| 32 words = string[dartx.split](" "); |
| 33 v8_regexp_utils.assertEquals("Friends,", words[dartx.get](0)); |
| 34 }; |
| 35 dart.fn(results$45cache_test.main, VoidTovoid$()); |
| 36 v8_regexp_utils.assertEquals = function(actual, expected, message) { |
| 37 if (message === void 0) message = null; |
| 38 expect$.Expect.equals(actual, expected, message); |
| 39 }; |
| 40 dart.fn(v8_regexp_utils.assertEquals, dynamicAnddynamic__Tovoid()); |
| 41 v8_regexp_utils.assertTrue = function(actual, message) { |
| 42 if (message === void 0) message = null; |
| 43 expect$.Expect.isTrue(actual, message); |
| 44 }; |
| 45 dart.fn(v8_regexp_utils.assertTrue, dynamic__Tovoid()); |
| 46 v8_regexp_utils.assertFalse = function(actual, message) { |
| 47 if (message === void 0) message = null; |
| 48 expect$.Expect.isFalse(actual, message); |
| 49 }; |
| 50 dart.fn(v8_regexp_utils.assertFalse, dynamic__Tovoid()); |
| 51 v8_regexp_utils.assertThrows = function(fn, testid) { |
| 52 if (testid === void 0) testid = null; |
| 53 expect$.Expect.throws(VoidTovoid()._check(fn), null, dart.str`Test ${testid}
`); |
| 54 }; |
| 55 dart.fn(v8_regexp_utils.assertThrows, dynamic__Tovoid$()); |
| 56 v8_regexp_utils.assertNull = function(actual, testid) { |
| 57 if (testid === void 0) testid = null; |
| 58 expect$.Expect.isNull(actual, dart.str`Test ${testid}`); |
| 59 }; |
| 60 dart.fn(v8_regexp_utils.assertNull, dynamic__Tovoid$()); |
| 61 v8_regexp_utils.assertToStringEquals = function(str, match, testid) { |
| 62 let actual = []; |
| 63 for (let i = 0; i <= dart.notNull(core.num._check(dart.dload(match, 'groupCo
unt'))); i++) { |
| 64 let g = dart.dsend(match, 'group', i); |
| 65 actual[dartx.add](g == null ? "" : g); |
| 66 } |
| 67 expect$.Expect.equals(str, actual[dartx.join](","), dart.str`Test ${testid}`
); |
| 68 }; |
| 69 dart.fn(v8_regexp_utils.assertToStringEquals, dynamicAnddynamicAndnumTovoid())
; |
| 70 v8_regexp_utils.shouldBeTrue = function(actual) { |
| 71 expect$.Expect.isTrue(actual); |
| 72 }; |
| 73 dart.fn(v8_regexp_utils.shouldBeTrue, dynamicTovoid()); |
| 74 v8_regexp_utils.shouldBeFalse = function(actual) { |
| 75 expect$.Expect.isFalse(actual); |
| 76 }; |
| 77 dart.fn(v8_regexp_utils.shouldBeFalse, dynamicTovoid()); |
| 78 v8_regexp_utils.shouldBeNull = function(actual) { |
| 79 expect$.Expect.isNull(actual); |
| 80 }; |
| 81 dart.fn(v8_regexp_utils.shouldBeNull, dynamicTovoid()); |
| 82 v8_regexp_utils.shouldBe = function(actual, expected, message) { |
| 83 if (message === void 0) message = null; |
| 84 if (expected == null) { |
| 85 expect$.Expect.isNull(actual, message); |
| 86 } else { |
| 87 expect$.Expect.equals(dart.dload(expected, 'length'), dart.dsend(dart.dloa
d(actual, 'groupCount'), '+', 1)); |
| 88 for (let i = 0; i <= dart.notNull(core.num._check(dart.dload(actual, 'grou
pCount'))); i++) { |
| 89 expect$.Expect.equals(dart.dindex(expected, i), dart.dsend(actual, 'grou
p', i), message); |
| 90 } |
| 91 } |
| 92 }; |
| 93 dart.fn(v8_regexp_utils.shouldBe, dynamicAnddynamic__Tovoid()); |
| 94 v8_regexp_utils.firstMatch = function(str, pattern) { |
| 95 return pattern.firstMatch(str); |
| 96 }; |
| 97 dart.fn(v8_regexp_utils.firstMatch, StringAndRegExpToMatch()); |
| 98 v8_regexp_utils.allStringMatches = function(str, pattern) { |
| 99 return pattern.allMatches(str)[dartx.map](core.String)(dart.fn(m => m.group(
0), MatchToString()))[dartx.toList](); |
| 100 }; |
| 101 dart.fn(v8_regexp_utils.allStringMatches, StringAndRegExpToListOfString()); |
| 102 v8_regexp_utils.description = function(str) { |
| 103 }; |
| 104 dart.fn(v8_regexp_utils.description, dynamicTovoid()); |
| 105 // Exports: |
| 106 exports.results$45cache_test = results$45cache_test; |
| 107 exports.v8_regexp_utils = v8_regexp_utils; |
| 108 }); |
OLD | NEW |