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

Side by Side Diff: test/codegen/expect/corelib/string_split_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 months 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
OLDNEW
(Empty)
1 dart_library.library('corelib/string_split_test', null, /* Imports */[
2 'dart_sdk',
3 'expect'
4 ], function load__string_split_test(exports, dart_sdk, expect) {
5 'use strict';
6 const core = dart_sdk.core;
7 const _interceptors = dart_sdk._interceptors;
8 const dart = dart_sdk.dart;
9 const dartx = dart_sdk.dartx;
10 const expect$ = expect.expect;
11 const string_split_test = Object.create(null);
12 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr ray$(core.String)))();
13 let IterableOfMatch = () => (IterableOfMatch = dart.constFn(core.Iterable$(cor e.Match)))();
14 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
15 let ListAndStringAndPatternTodynamic = () => (ListAndStringAndPatternTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.List, core.String, core.Pattern])))();
16 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))();
17 let dynamicToRegExp = () => (dynamicToRegExp = dart.constFn(dart.definiteFunct ionType(core.RegExp, [dart.dynamic])))();
18 let dynamicToRegExpWrap = () => (dynamicToRegExpWrap = dart.constFn(dart.defin iteFunctionType(string_split_test.RegExpWrap, [dart.dynamic])))();
19 let dynamicTovoid = () => (dynamicTovoid = dart.constFn(dart.definiteFunctionT ype(dart.void, [dart.dynamic])))();
20 string_split_test.main = function() {
21 string_split_test.testSplitString();
22 string_split_test.testSplitRegExp();
23 string_split_test.testSplitPattern();
24 };
25 dart.fn(string_split_test.main, VoidTodynamic());
26 string_split_test.testSplit = function(expect, string, pattern) {
27 let patternString = null;
28 if (typeof pattern == 'string') {
29 patternString = dart.str`"${pattern}"`;
30 } else if (core.RegExp.is(pattern)) {
31 patternString = dart.str`/${pattern.pattern}/`;
32 } else {
33 patternString = dart.toString(pattern);
34 }
35 expect$.Expect.listEquals(expect, string[dartx.split](pattern), dart.str`"${ string}".split(${patternString})`);
36 };
37 dart.fn(string_split_test.testSplit, ListAndStringAndPatternTodynamic());
38 string_split_test.testSplitString = function() {
39 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "a b c", " ");
40 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "adbdc", "d");
41 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "addbddc" , "dd");
42 string_split_test.testSplit(JSArrayOfString().of(["abc"]), "abc", " ");
43 string_split_test.testSplit(JSArrayOfString().of(["a"]), "a", "b");
44 string_split_test.testSplit(JSArrayOfString().of([""]), "", "b");
45 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "abc", "" );
46 string_split_test.testSplit(JSArrayOfString().of(["", "", "", "", ""]), "aaa a", "a");
47 string_split_test.testSplit(JSArrayOfString().of(["", "", "", "", ""]), " ", " ");
48 string_split_test.testSplit(JSArrayOfString().of(["", ""]), "a", "a");
49 string_split_test.testSplit(JSArrayOfString().of(["", "", "", "a"]), "aaaaaa a", "aa");
50 string_split_test.testSplit([], "", "");
51 string_split_test.testSplit(JSArrayOfString().of([""]), "", "a");
52 };
53 dart.fn(string_split_test.testSplitString, VoidTovoid());
54 string_split_test.testSplitRegExp = function() {
55 string_split_test.testSplitWithRegExp(dart.fn(s => core.RegExp.new(core.Stri ng._check(s)), dynamicToRegExp()));
56 };
57 dart.fn(string_split_test.testSplitRegExp, VoidTovoid());
58 string_split_test.testSplitPattern = function() {
59 string_split_test.testSplitWithRegExp(dart.fn(s => new string_split_test.Reg ExpWrap(core.String._check(s)), dynamicToRegExpWrap()));
60 };
61 dart.fn(string_split_test.testSplitPattern, VoidTovoid());
62 string_split_test.testSplitWithRegExp = function(makePattern) {
63 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "a b c", core.Pattern._check(dart.dcall(makePattern, " ")));
64 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "adbdc", core.Pattern._check(dart.dcall(makePattern, "[dz]")));
65 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "addbddc" , core.Pattern._check(dart.dcall(makePattern, "dd")));
66 string_split_test.testSplit(JSArrayOfString().of(["abc"]), "abc", core.Patte rn._check(dart.dcall(makePattern, "b$")));
67 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "abc", co re.Pattern._check(dart.dcall(makePattern, "")));
68 string_split_test.testSplit(JSArrayOfString().of(["", "", "", ""]), " ", c ore.Pattern._check(dart.dcall(makePattern, "[ ]")));
69 string_split_test.testSplit(JSArrayOfString().of(["aa", ""]), "aaa", core.Pa ttern._check(dart.dcall(makePattern, "a$")));
70 string_split_test.testSplit(JSArrayOfString().of(["aaa"]), "aaa", core.Patte rn._check(dart.dcall(makePattern, "$")));
71 string_split_test.testSplit(JSArrayOfString().of(["", "aa"]), "aaa", core.Pa ttern._check(dart.dcall(makePattern, "^a")));
72 string_split_test.testSplit(JSArrayOfString().of(["aaa"]), "aaa", core.Patte rn._check(dart.dcall(makePattern, "^")));
73 string_split_test.testSplit(JSArrayOfString().of(["", "", "", "a"]), "aaaaaa a", core.Pattern._check(dart.dcall(makePattern, "aa|aaa")));
74 string_split_test.testSplit(JSArrayOfString().of(["", "", "", "a"]), "aaaaaa a", core.Pattern._check(dart.dcall(makePattern, "aa|")));
75 string_split_test.testSplit(JSArrayOfString().of(["", "", "a"]), "aaaaaaa", core.Pattern._check(dart.dcall(makePattern, "aaa|aa")));
76 string_split_test.testSplit(JSArrayOfString().of(["a", "bc"]), "abc", core.P attern._check(dart.dcall(makePattern, "(?=[ab])")));
77 string_split_test.testSplit(JSArrayOfString().of(["a", "b", "c"]), "abc", co re.Pattern._check(dart.dcall(makePattern, "(?!^)")));
78 string_split_test.testSplit([], "", core.Pattern._check(dart.dcall(makePatte rn, "")));
79 string_split_test.testSplit([], "", core.Pattern._check(dart.dcall(makePatte rn, "(?:)")));
80 string_split_test.testSplit([], "", core.Pattern._check(dart.dcall(makePatte rn, "$|(?=.)")));
81 string_split_test.testSplit(JSArrayOfString().of([""]), "", core.Pattern._ch eck(dart.dcall(makePattern, "a")));
82 string_split_test.testSplit(JSArrayOfString().of(["", ""]), "a", core.Patter n._check(dart.dcall(makePattern, "a")));
83 string_split_test.testSplit(JSArrayOfString().of(["a"]), "a", core.Pattern._ check(dart.dcall(makePattern, "b")));
84 string_split_test.testSplit(JSArrayOfString().of(["a", "", "a"]), "abba", co re.Pattern._check(dart.dcall(makePattern, "(b)")));
85 string_split_test.testSplit(JSArrayOfString().of(["a", "a"]), "abba", core.P attern._check(dart.dcall(makePattern, "(bb)")));
86 string_split_test.testSplit(JSArrayOfString().of(["a", "a"]), "abba", core.P attern._check(dart.dcall(makePattern, "(b*)")));
87 string_split_test.testSplit(JSArrayOfString().of(["a", "a"]), "aa", core.Pat tern._check(dart.dcall(makePattern, "(b*)")));
88 string_split_test.testSplit(JSArrayOfString().of(["a", "cba"]), "abcba", cor e.Pattern._check(dart.dcall(makePattern, "([bc])(?=.*\\1)")));
89 };
90 dart.fn(string_split_test.testSplitWithRegExp, dynamicTovoid());
91 string_split_test.RegExpWrap = class RegExpWrap extends core.Object {
92 new(source) {
93 this.regexp = core.RegExp.new(source);
94 }
95 allMatches(string, start) {
96 if (start === void 0) start = 0;
97 return IterableOfMatch()._check(dart.dsend(this.regexp, 'allMatches', stri ng, start));
98 }
99 matchAsPrefix(string, start) {
100 if (start === void 0) start = 0;
101 return core.Match._check(dart.dsend(this.regexp, 'matchAsPrefix', string, start));
102 }
103 toString() {
104 return dart.str`Wrap(/${dart.dload(this.regexp, 'pattern')}/)`;
105 }
106 };
107 string_split_test.RegExpWrap[dart.implements] = () => [core.Pattern];
108 dart.setSignature(string_split_test.RegExpWrap, {
109 constructors: () => ({new: dart.definiteFunctionType(string_split_test.RegEx pWrap, [core.String])}),
110 methods: () => ({
111 allMatches: dart.definiteFunctionType(core.Iterable$(core.Match), [core.St ring], [core.int]),
112 matchAsPrefix: dart.definiteFunctionType(core.Match, [core.String], [core. int])
113 })
114 });
115 dart.defineExtensionMembers(string_split_test.RegExpWrap, ['allMatches', 'matc hAsPrefix']);
116 // Exports:
117 exports.string_split_test = string_split_test;
118 });
OLDNEW
« no previous file with comments | « test/codegen/expect/corelib/string_source_test.js ('k') | test/codegen/expect/corelib/string_substring_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698