OLD | NEW |
(Empty) | |
| 1 dart_library.library('corelib/regexp/backreferences_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__backreferences_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 backreferences_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 backreferences_test.main = function() { |
| 24 v8_regexp_utils.description("Test to ensure correct behaviour when using bac
kreferences in a RegExp"); |
| 25 v8_regexp_utils.shouldBeTrue(core.RegExp.new("(...)\\1$").hasMatch('abcabc')
); |
| 26 v8_regexp_utils.shouldBeFalse(core.RegExp.new("(...)\\1$").hasMatch('abcdef'
)); |
| 27 v8_regexp_utils.shouldBeFalse(core.RegExp.new("(...)\\2$").hasMatch('abcabc'
)); |
| 28 v8_regexp_utils.shouldBeFalse(core.RegExp.new("(...)\\2$").hasMatch('abc')); |
| 29 v8_regexp_utils.shouldBeTrue(core.RegExp.new("\\1(...)$").hasMatch('abcabc')
); |
| 30 v8_regexp_utils.shouldBeTrue(core.RegExp.new("\\1(...)$").hasMatch('abcdef')
); |
| 31 v8_regexp_utils.shouldBeFalse(core.RegExp.new("\\2(...)$").hasMatch('abcabc'
)); |
| 32 v8_regexp_utils.shouldBeFalse(core.RegExp.new("\\2(...)$").hasMatch('abc')); |
| 33 v8_regexp_utils.shouldBeTrue(core.RegExp.new("\\1?(...)$").hasMatch('abc')); |
| 34 v8_regexp_utils.shouldBeTrue(core.RegExp.new("\\1?(...)$").hasMatch('abc')); |
| 35 let re = core.RegExp.new("[^b]*((..)|(\\2))+Sz", {caseSensitive: false}); |
| 36 v8_regexp_utils.shouldBeFalse(re.hasMatch('axabcd')); |
| 37 v8_regexp_utils.shouldBeTrue(re.hasMatch('axabcsz')); |
| 38 }; |
| 39 dart.fn(backreferences_test.main, VoidTovoid$()); |
| 40 v8_regexp_utils.assertEquals = function(actual, expected, message) { |
| 41 if (message === void 0) message = null; |
| 42 expect$.Expect.equals(actual, expected, message); |
| 43 }; |
| 44 dart.fn(v8_regexp_utils.assertEquals, dynamicAnddynamic__Tovoid()); |
| 45 v8_regexp_utils.assertTrue = function(actual, message) { |
| 46 if (message === void 0) message = null; |
| 47 expect$.Expect.isTrue(actual, message); |
| 48 }; |
| 49 dart.fn(v8_regexp_utils.assertTrue, dynamic__Tovoid()); |
| 50 v8_regexp_utils.assertFalse = function(actual, message) { |
| 51 if (message === void 0) message = null; |
| 52 expect$.Expect.isFalse(actual, message); |
| 53 }; |
| 54 dart.fn(v8_regexp_utils.assertFalse, dynamic__Tovoid()); |
| 55 v8_regexp_utils.assertThrows = function(fn, testid) { |
| 56 if (testid === void 0) testid = null; |
| 57 expect$.Expect.throws(VoidTovoid()._check(fn), null, dart.str`Test ${testid}
`); |
| 58 }; |
| 59 dart.fn(v8_regexp_utils.assertThrows, dynamic__Tovoid$()); |
| 60 v8_regexp_utils.assertNull = function(actual, testid) { |
| 61 if (testid === void 0) testid = null; |
| 62 expect$.Expect.isNull(actual, dart.str`Test ${testid}`); |
| 63 }; |
| 64 dart.fn(v8_regexp_utils.assertNull, dynamic__Tovoid$()); |
| 65 v8_regexp_utils.assertToStringEquals = function(str, match, testid) { |
| 66 let actual = []; |
| 67 for (let i = 0; i <= dart.notNull(core.num._check(dart.dload(match, 'groupCo
unt'))); i++) { |
| 68 let g = dart.dsend(match, 'group', i); |
| 69 actual[dartx.add](g == null ? "" : g); |
| 70 } |
| 71 expect$.Expect.equals(str, actual[dartx.join](","), dart.str`Test ${testid}`
); |
| 72 }; |
| 73 dart.fn(v8_regexp_utils.assertToStringEquals, dynamicAnddynamicAndnumTovoid())
; |
| 74 v8_regexp_utils.shouldBeTrue = function(actual) { |
| 75 expect$.Expect.isTrue(actual); |
| 76 }; |
| 77 dart.fn(v8_regexp_utils.shouldBeTrue, dynamicTovoid()); |
| 78 v8_regexp_utils.shouldBeFalse = function(actual) { |
| 79 expect$.Expect.isFalse(actual); |
| 80 }; |
| 81 dart.fn(v8_regexp_utils.shouldBeFalse, dynamicTovoid()); |
| 82 v8_regexp_utils.shouldBeNull = function(actual) { |
| 83 expect$.Expect.isNull(actual); |
| 84 }; |
| 85 dart.fn(v8_regexp_utils.shouldBeNull, dynamicTovoid()); |
| 86 v8_regexp_utils.shouldBe = function(actual, expected, message) { |
| 87 if (message === void 0) message = null; |
| 88 if (expected == null) { |
| 89 expect$.Expect.isNull(actual, message); |
| 90 } else { |
| 91 expect$.Expect.equals(dart.dload(expected, 'length'), dart.dsend(dart.dloa
d(actual, 'groupCount'), '+', 1)); |
| 92 for (let i = 0; i <= dart.notNull(core.num._check(dart.dload(actual, 'grou
pCount'))); i++) { |
| 93 expect$.Expect.equals(dart.dindex(expected, i), dart.dsend(actual, 'grou
p', i), message); |
| 94 } |
| 95 } |
| 96 }; |
| 97 dart.fn(v8_regexp_utils.shouldBe, dynamicAnddynamic__Tovoid()); |
| 98 v8_regexp_utils.firstMatch = function(str, pattern) { |
| 99 return pattern.firstMatch(str); |
| 100 }; |
| 101 dart.fn(v8_regexp_utils.firstMatch, StringAndRegExpToMatch()); |
| 102 v8_regexp_utils.allStringMatches = function(str, pattern) { |
| 103 return pattern.allMatches(str)[dartx.map](core.String)(dart.fn(m => m.group(
0), MatchToString()))[dartx.toList](); |
| 104 }; |
| 105 dart.fn(v8_regexp_utils.allStringMatches, StringAndRegExpToListOfString()); |
| 106 v8_regexp_utils.description = function(str) { |
| 107 }; |
| 108 dart.fn(v8_regexp_utils.description, dynamicTovoid()); |
| 109 // Exports: |
| 110 exports.backreferences_test = backreferences_test; |
| 111 exports.v8_regexp_utils = v8_regexp_utils; |
| 112 }); |
OLD | NEW |