OLD | NEW |
(Empty) | |
| 1 dart_library.library('corelib/string_replace_all_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__string_replace_all_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 string_replace_all_test = Object.create(null); |
| 11 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 12 let MatchToString = () => (MatchToString = dart.constFn(dart.definiteFunctionT
ype(core.String, [core.Match])))(); |
| 13 let StringToString = () => (StringToString = dart.constFn(dart.definiteFunctio
nType(core.String, [core.String])))(); |
| 14 string_replace_all_test.testReplaceAll = function() { |
| 15 expect$.Expect.equals("aXXcaXXdae", "abcabdae"[dartx.replaceAll]("b", "XX"))
; |
| 16 expect$.Expect.equals("XXbcXXbdXXe", "abcabdae"[dartx.replaceAll]("a", "XX")
); |
| 17 expect$.Expect.equals("abcabdaXX", "abcabdae"[dartx.replaceAll]("e", "XX")); |
| 18 expect$.Expect.equals("abcabdae", "abcabdae"[dartx.replaceAll]("f", "XX")); |
| 19 expect$.Expect.equals("", ""[dartx.replaceAll]("from", "to")); |
| 20 expect$.Expect.equals("fro", "fro"[dartx.replaceAll]("from", "to")); |
| 21 expect$.Expect.equals("to", "from"[dartx.replaceAll]("from", "to")); |
| 22 expect$.Expect.equals("toto", "fromfrom"[dartx.replaceAll]("from", "to")); |
| 23 expect$.Expect.equals("to", "to"[dartx.replaceAll]("from", "to")); |
| 24 expect$.Expect.equals("bcbde", "abcabdae"[dartx.replaceAll]("a", "")); |
| 25 expect$.Expect.equals("AB", "AfromB"[dartx.replaceAll]("from", "")); |
| 26 expect$.Expect.equals("to", ""[dartx.replaceAll]("", "to")); |
| 27 expect$.Expect.equals("toAtoBtoCto", "ABC"[dartx.replaceAll]("", "to")); |
| 28 expect$.Expect.equals("$$", "||"[dartx.replaceAll]("|", "$")); |
| 29 expect$.Expect.equals("$$$$", "||"[dartx.replaceAll]("|", "$$")); |
| 30 expect$.Expect.equals("x$|x", "x|.|x"[dartx.replaceAll]("|.", "$")); |
| 31 expect$.Expect.equals("$$", ".."[dartx.replaceAll](".", "$")); |
| 32 expect$.Expect.equals("[$$$$]", "[..]"[dartx.replaceAll](".", "$$")); |
| 33 expect$.Expect.equals("[$]", "[..]"[dartx.replaceAll]("..", "$")); |
| 34 expect$.Expect.equals("$$", "\\\\"[dartx.replaceAll]("\\", "$")); |
| 35 }; |
| 36 dart.fn(string_replace_all_test.testReplaceAll, VoidTodynamic()); |
| 37 string_replace_all_test.testReplaceAllMapped = function() { |
| 38 function mark(m) { |
| 39 return dart.str`[${m.get(0)}]`; |
| 40 } |
| 41 dart.fn(mark, MatchToString()); |
| 42 expect$.Expect.equals("a[b]ca[b]dae", "abcabdae"[dartx.replaceAllMapped]("b"
, mark)); |
| 43 expect$.Expect.equals("[a]bc[a]bd[a]e", "abcabdae"[dartx.replaceAllMapped]("
a", mark)); |
| 44 expect$.Expect.equals("abcabda[e]", "abcabdae"[dartx.replaceAllMapped]("e",
mark)); |
| 45 expect$.Expect.equals("abcabdae", "abcabdae"[dartx.replaceAllMapped]("f", ma
rk)); |
| 46 expect$.Expect.equals("", ""[dartx.replaceAllMapped]("from", mark)); |
| 47 expect$.Expect.equals("fro", "fro"[dartx.replaceAllMapped]("from", mark)); |
| 48 expect$.Expect.equals("[from][from]", "fromfrom"[dartx.replaceAllMapped]("fr
om", mark)); |
| 49 expect$.Expect.equals("bcbde", "abcabdae"[dartx.replaceAllMapped]("a", dart.
fn(m => "", MatchToString()))); |
| 50 expect$.Expect.equals("AB", "AfromB"[dartx.replaceAllMapped]("from", dart.fn
(m => "", MatchToString()))); |
| 51 expect$.Expect.equals("[]", ""[dartx.replaceAllMapped]("", mark)); |
| 52 expect$.Expect.equals("[]A[]B[]C[]", "ABC"[dartx.replaceAllMapped]("", mark)
); |
| 53 }; |
| 54 dart.fn(string_replace_all_test.testReplaceAllMapped, VoidTodynamic()); |
| 55 string_replace_all_test.testSplitMapJoin = function() { |
| 56 function mark(m) { |
| 57 return dart.str`[${m.get(0)}]`; |
| 58 } |
| 59 dart.fn(mark, MatchToString()); |
| 60 function wrap(s) { |
| 61 return dart.str`<${s}>`; |
| 62 } |
| 63 dart.fn(wrap, StringToString()); |
| 64 expect$.Expect.equals("<a>[b]<ca>[b]<dae>", "abcabdae"[dartx.splitMapJoin]("
b", {onMatch: mark, onNonMatch: wrap})); |
| 65 expect$.Expect.equals("<>[a]<bc>[a]<bd>[a]<e>", "abcabdae"[dartx.splitMapJoi
n]("a", {onMatch: mark, onNonMatch: wrap})); |
| 66 expect$.Expect.equals("<abcabda>[e]<>", "abcabdae"[dartx.splitMapJoin]("e",
{onMatch: mark, onNonMatch: wrap})); |
| 67 expect$.Expect.equals("<abcabdae>", "abcabdae"[dartx.splitMapJoin]("f", {onM
atch: mark, onNonMatch: wrap})); |
| 68 expect$.Expect.equals("<>", ""[dartx.splitMapJoin]("from", {onMatch: mark, o
nNonMatch: wrap})); |
| 69 expect$.Expect.equals("<fro>", "fro"[dartx.splitMapJoin]("from", {onMatch: m
ark, onNonMatch: wrap})); |
| 70 expect$.Expect.equals("<>[from]<>[from]<>", "fromfrom"[dartx.splitMapJoin]("
from", {onMatch: mark, onNonMatch: wrap})); |
| 71 expect$.Expect.equals("<>[]<>", ""[dartx.splitMapJoin]("", {onMatch: mark, o
nNonMatch: wrap})); |
| 72 expect$.Expect.equals("<>[]<A>[]<B>[]<C>[]<>", "ABC"[dartx.splitMapJoin]("",
{onMatch: mark, onNonMatch: wrap})); |
| 73 expect$.Expect.equals("[a]bc[a]bd[a]e", "abcabdae"[dartx.splitMapJoin]("a",
{onMatch: mark})); |
| 74 expect$.Expect.equals("<>a<bc>a<bd>a<e>", "abcabdae"[dartx.splitMapJoin]("a"
, {onNonMatch: wrap})); |
| 75 }; |
| 76 dart.fn(string_replace_all_test.testSplitMapJoin, VoidTodynamic()); |
| 77 string_replace_all_test.main = function() { |
| 78 string_replace_all_test.testReplaceAll(); |
| 79 string_replace_all_test.testReplaceAllMapped(); |
| 80 string_replace_all_test.testSplitMapJoin(); |
| 81 }; |
| 82 dart.fn(string_replace_all_test.main, VoidTodynamic()); |
| 83 // Exports: |
| 84 exports.string_replace_all_test = string_replace_all_test; |
| 85 }); |
OLD | NEW |