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

Side by Side Diff: test/codegen/expect/lib/convert/streamed_conversion_json_utf8_encode_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('lib/convert/streamed_conversion_json_utf8_encode_test', nu ll, /* Imports */[
2 'dart_sdk',
3 'async_helper',
4 'expect'
5 ], function load__streamed_conversion_json_utf8_encode_test(exports, dart_sdk, a sync_helper, expect) {
6 'use strict';
7 const core = dart_sdk.core;
8 const convert = dart_sdk.convert;
9 const async = dart_sdk.async;
10 const _interceptors = dart_sdk._interceptors;
11 const dart = dart_sdk.dart;
12 const dartx = dart_sdk.dartx;
13 const async_helper$ = async_helper.async_helper;
14 const expect$ = expect.expect;
15 const streamed_conversion_json_utf8_encode_test = Object.create(null);
16 const json_unicode_tests = Object.create(null);
17 const unicode_tests = Object.create(null);
18 let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))();
19 let StreamOfListOfint = () => (StreamOfListOfint = dart.constFn(async.Stream$( ListOfint())))();
20 let JSArrayOfList = () => (JSArrayOfList = dart.constFn(_interceptors.JSArray$ (core.List)))();
21 let ListOfList = () => (ListOfList = dart.constFn(core.List$(core.List)))();
22 let JSArrayOfListOfList = () => (JSArrayOfListOfList = dart.constFn(_intercept ors.JSArray$(ListOfList())))();
23 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c ore.int)))();
24 let ListOfListOfList = () => (ListOfListOfList = dart.constFn(core.List$(ListO fList())))();
25 let JSArrayOfListOfListOfList = () => (JSArrayOfListOfListOfList = dart.constF n(_interceptors.JSArray$(ListOfListOfList())))();
26 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr ray$(core.Object)))();
27 let ListOfObject = () => (ListOfObject = dart.constFn(core.List$(core.Object)) )();
28 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))();
29 let ObjectToStreamOfListOfint = () => (ObjectToStreamOfListOfint = dart.constF n(dart.definiteFunctionType(StreamOfListOfint(), [core.Object])))();
30 let ListTodynamic = () => (ListTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [core.List])))();
31 let ListOfintAndStreamTovoid = () => (ListOfintAndStreamTovoid = dart.constFn( dart.definiteFunctionType(dart.void, [ListOfint(), async.Stream])))();
32 let dynamicTovoid = () => (dynamicTovoid = dart.constFn(dart.definiteFunctionT ype(dart.void, [dart.dynamic])))();
33 let dynamicToIterable = () => (dynamicToIterable = dart.constFn(dart.definiteF unctionType(core.Iterable, [dart.dynamic])))();
34 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
35 let ListOfObjectToListOfObject = () => (ListOfObjectToListOfObject = dart.cons tFn(dart.definiteFunctionType(ListOfObject(), [ListOfObject()])))();
36 let VoidToListOfList = () => (VoidToListOfList = dart.constFn(dart.definiteFun ctionType(ListOfList(), [])))();
37 dart.defineLazy(streamed_conversion_json_utf8_encode_test, {
38 get JSON_UTF8() {
39 return convert.JSON.fuse(convert.UTF8);
40 }
41 });
42 streamed_conversion_json_utf8_encode_test.encode = function(o) {
43 let controller = null;
44 controller = async.StreamController.new({onListen: dart.fn(() => {
45 dart.dsend(controller, 'add', o);
46 dart.dsend(controller, 'close');
47 }, VoidTovoid())});
48 return StreamOfListOfint()._check(dart.dsend(dart.dload(controller, 'stream' ), 'transform', streamed_conversion_json_utf8_encode_test.JSON_UTF8.encoder));
49 };
50 dart.fn(streamed_conversion_json_utf8_encode_test.encode, ObjectToStreamOfList Ofint());
51 streamed_conversion_json_utf8_encode_test.testUnpaused = function(expected, st ream) {
52 async_helper$.asyncStart();
53 stream.toList().then(dart.dynamic)(dart.fn(list => {
54 let combined = [];
55 list[dartx.forEach](dart.bind(combined, dartx.addAll));
56 expect$.Expect.listEquals(expected, combined);
57 async_helper$.asyncEnd();
58 }, ListTodynamic()));
59 };
60 dart.fn(streamed_conversion_json_utf8_encode_test.testUnpaused, ListOfintAndSt reamTovoid());
61 streamed_conversion_json_utf8_encode_test.testWithPauses = function(expected, stream) {
62 async_helper$.asyncStart();
63 let accumulated = [];
64 let sub = null;
65 sub = stream.listen(dart.fn(x => {
66 accumulated[dartx.addAll](core.Iterable._check(x));
67 dart.dsend(sub, 'pause', async.Future.delayed(core.Duration.ZERO));
68 }, dynamicTovoid()), {onDone: dart.fn(() => {
69 expect$.Expect.listEquals(expected, accumulated);
70 async_helper$.asyncEnd();
71 }, VoidTovoid())});
72 };
73 dart.fn(streamed_conversion_json_utf8_encode_test.testWithPauses, ListOfintAnd StreamTovoid());
74 streamed_conversion_json_utf8_encode_test.main = function() {
75 for (let test of core.Iterable._check(json_unicode_tests.JSON_UNICODE_TESTS) ) {
76 let expected = dart.dindex(test, 0);
77 let object = dart.dindex(test, 1);
78 streamed_conversion_json_utf8_encode_test.testUnpaused(ListOfint()._check( expected), streamed_conversion_json_utf8_encode_test.encode(object));
79 streamed_conversion_json_utf8_encode_test.testWithPauses(ListOfint()._chec k(expected), streamed_conversion_json_utf8_encode_test.encode(object));
80 }
81 };
82 dart.fn(streamed_conversion_json_utf8_encode_test.main, VoidTovoid());
83 json_unicode_tests._QUOTE = 34;
84 json_unicode_tests._COLON = 58;
85 json_unicode_tests._COMMA = 44;
86 json_unicode_tests._BRACE_OPEN = 123;
87 json_unicode_tests._BRACE_CLOSE = 125;
88 json_unicode_tests._BRACKET_OPEN = 91;
89 json_unicode_tests._BRACKET_CLOSE = 93;
90 json_unicode_tests._expandUnicodeTests = function() {
91 return unicode_tests.UNICODE_TESTS[dartx.expand](dart.dynamic)(dart.fn(test => {
92 dart.assert(!dart.test(dart.dsend(test, 'contains', '"')));
93 let bytes = dart.dindex(test, 0);
94 let string = dart.dindex(test, 1);
95 let expanded = [];
96 let inQuotesBytes = [];
97 inQuotesBytes[dartx.add](json_unicode_tests._QUOTE);
98 inQuotesBytes[dartx.addAll](core.Iterable._check(bytes));
99 inQuotesBytes[dartx.add](json_unicode_tests._QUOTE);
100 expanded[dartx.add]([inQuotesBytes, string]);
101 let listExpected = JSArrayOfListOfList().of([JSArrayOfList().of([[string]] )]);
102 let inListBytes = [];
103 inListBytes[dartx.addAll](JSArrayOfint().of([json_unicode_tests._BRACKET_O PEN, json_unicode_tests._BRACKET_OPEN, json_unicode_tests._BRACKET_OPEN]));
104 inListBytes[dartx.addAll](inQuotesBytes);
105 inListBytes[dartx.addAll](JSArrayOfint().of([json_unicode_tests._BRACKET_C LOSE, json_unicode_tests._BRACKET_CLOSE, json_unicode_tests._BRACKET_CLOSE]));
106 expanded[dartx.add](JSArrayOfList().of([inListBytes, listExpected]));
107 let listLongerExpected = JSArrayOfListOfListOfList().of([listExpected, lis tExpected, listExpected]);
108 let listLongerBytes = [];
109 listLongerBytes[dartx.add](json_unicode_tests._BRACKET_OPEN);
110 listLongerBytes[dartx.addAll](inListBytes);
111 listLongerBytes[dartx.add](json_unicode_tests._COMMA);
112 listLongerBytes[dartx.addAll](inListBytes);
113 listLongerBytes[dartx.add](json_unicode_tests._COMMA);
114 listLongerBytes[dartx.addAll](inListBytes);
115 listLongerBytes[dartx.add](json_unicode_tests._BRACKET_CLOSE);
116 expanded[dartx.add](JSArrayOfList().of([listLongerBytes, listLongerExpecte d]));
117 let mapExpected = core.Map.new();
118 mapExpected[dartx.set](string, listLongerExpected);
119 let mapBytes = [];
120 mapBytes[dartx.add](json_unicode_tests._BRACE_OPEN);
121 mapBytes[dartx.addAll](inQuotesBytes);
122 mapBytes[dartx.add](json_unicode_tests._COLON);
123 mapBytes[dartx.addAll](listLongerBytes);
124 mapBytes[dartx.add](json_unicode_tests._BRACE_CLOSE);
125 expanded[dartx.add](JSArrayOfObject().of([mapBytes, mapExpected]));
126 return expanded;
127 }, dynamicToIterable()))[dartx.toList]();
128 };
129 dart.fn(json_unicode_tests._expandUnicodeTests, VoidTodynamic());
130 dart.defineLazy(json_unicode_tests, {
131 get JSON_UNICODE_TESTS() {
132 return json_unicode_tests._expandUnicodeTests();
133 }
134 });
135 unicode_tests.INTER_BYTES = dart.constList([195, 142, 195, 177, 197, 163, 195, 169, 114, 195, 177, 195, 165, 197, 163, 195, 174, 195, 182, 195, 177, 195, 165, 196, 188, 195, 174, 197, 190, 195, 165, 197, 163, 195, 174, 225, 187, 157, 195, 177], core.int);
136 unicode_tests.INTER_STRING = "Îñţérñåţîöñåļîžåţîờñ";
137 unicode_tests.BLUEBERRY_BYTES = dart.constList([98, 108, 195, 165, 98, 195, 16 6, 114, 103, 114, 195, 184, 100], core.int);
138 unicode_tests.BLUEBERRY_STRING = "blåbærgrød";
139 unicode_tests.SIVA_BYTES1 = dart.constList([224, 174, 154, 224, 174, 191, 224, 174, 181, 224, 174, 190, 32, 224, 174, 133, 224, 174, 163, 224, 174, 190, 224, 174, 174, 224, 174, 190, 224, 175, 136, 224, 174, 178], core.int);
140 unicode_tests.SIVA_STRING1 = "சிவா அணாமாைல";
141 unicode_tests.SIVA_BYTES2 = dart.constList([224, 164, 191, 224, 164, 184, 224, 164, 181, 224, 164, 190, 32, 224, 164, 133, 224, 164, 163, 224, 164, 190, 224, 164, 174, 224, 164, 190, 224, 164, 178, 224, 165, 136], core.int);
142 unicode_tests.SIVA_STRING2 = "िसवा अणामालै";
143 unicode_tests.BEE_BYTES = dart.constList([240, 144, 144, 146], core.int);
144 unicode_tests.BEE_STRING = "𐐒";
145 unicode_tests.DIGIT_BYTES = dart.constList([53], core.int);
146 unicode_tests.DIGIT_STRING = "5";
147 unicode_tests.ASCII_BYTES = dart.constList([97, 98, 99, 100, 101, 102, 103, 10 4, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 12 0, 121, 122], core.int);
148 unicode_tests.ASCII_STRING = "abcdefghijklmnopqrstuvwxyz";
149 unicode_tests.BIGGEST_ASCII_BYTES = dart.constList([127], core.int);
150 unicode_tests.BIGGEST_ASCII_STRING = "";
151 unicode_tests.SMALLEST_2_UTF8_UNIT_BYTES = dart.constList([194, 128], core.int );
152 unicode_tests.SMALLEST_2_UTF8_UNIT_STRING = "€";
153 unicode_tests.BIGGEST_2_UTF8_UNIT_BYTES = dart.constList([223, 191], core.int) ;
154 unicode_tests.BIGGEST_2_UTF8_UNIT_STRING = "߿";
155 unicode_tests.SMALLEST_3_UTF8_UNIT_BYTES = dart.constList([224, 160, 128], cor e.int);
156 unicode_tests.SMALLEST_3_UTF8_UNIT_STRING = "ࠀ";
157 unicode_tests.BIGGEST_3_UTF8_UNIT_BYTES = dart.constList([239, 191, 191], core .int);
158 unicode_tests.BIGGEST_3_UTF8_UNIT_STRING = "￿";
159 unicode_tests.SMALLEST_4_UTF8_UNIT_BYTES = dart.constList([240, 144, 128, 128] , core.int);
160 unicode_tests.SMALLEST_4_UTF8_UNIT_STRING = "𐀀";
161 unicode_tests.BIGGEST_4_UTF8_UNIT_BYTES = dart.constList([244, 143, 191, 191], core.int);
162 unicode_tests.BIGGEST_4_UTF8_UNIT_STRING = "􏿿";
163 unicode_tests._TEST_PAIRS = dart.constList([dart.constList([dart.constList([], dart.dynamic), ""], core.Object), dart.constList([unicode_tests.INTER_BYTES, un icode_tests.INTER_STRING], core.Object), dart.constList([unicode_tests.BLUEBERRY _BYTES, unicode_tests.BLUEBERRY_STRING], core.Object), dart.constList([unicode_t ests.SIVA_BYTES1, unicode_tests.SIVA_STRING1], core.Object), dart.constList([uni code_tests.SIVA_BYTES2, unicode_tests.SIVA_STRING2], core.Object), dart.constLis t([unicode_tests.BEE_BYTES, unicode_tests.BEE_STRING], core.Object), dart.constL ist([unicode_tests.DIGIT_BYTES, unicode_tests.DIGIT_STRING], core.Object), dart. constList([unicode_tests.ASCII_BYTES, unicode_tests.ASCII_STRING], core.Object), dart.constList([unicode_tests.BIGGEST_ASCII_BYTES, unicode_tests.BIGGEST_ASCII_ STRING], core.Object), dart.constList([unicode_tests.SMALLEST_2_UTF8_UNIT_BYTES, unicode_tests.SMALLEST_2_UTF8_UNIT_STRING], core.Object), dart.constList([unico de_tests.BIGGEST_2_UTF8_UNIT_BYTES, unicode_tests.BIGGEST_2_UTF8_UNIT_STRING], c ore.Object), dart.constList([unicode_tests.SMALLEST_3_UTF8_UNIT_BYTES, unicode_t ests.SMALLEST_3_UTF8_UNIT_STRING], core.Object), dart.constList([unicode_tests.B IGGEST_3_UTF8_UNIT_BYTES, unicode_tests.BIGGEST_3_UTF8_UNIT_STRING], core.Object ), dart.constList([unicode_tests.SMALLEST_4_UTF8_UNIT_BYTES, unicode_tests.SMALL EST_4_UTF8_UNIT_STRING], core.Object), dart.constList([unicode_tests.BIGGEST_4_U TF8_UNIT_BYTES, unicode_tests.BIGGEST_4_UTF8_UNIT_STRING], core.Object)], ListOf Object());
164 unicode_tests._expandTestPairs = function() {
165 dart.assert(2 == unicode_tests.BEE_STRING[dartx.length]);
166 let tests = [];
167 tests[dartx.addAll](unicode_tests._TEST_PAIRS);
168 tests[dartx.addAll](unicode_tests._TEST_PAIRS[dartx.map](ListOfObject())(dar t.fn(test => {
169 let bytes = test[dartx.get](0);
170 let string = test[dartx.get](1);
171 let longBytes = [];
172 let longString = "";
173 for (let i = 0; i < 100; i++) {
174 longBytes[dartx.addAll](core.Iterable._check(bytes));
175 longString = dart.notNull(longString) + dart.notNull(core.String._check( string));
176 }
177 return JSArrayOfObject().of([longBytes, longString]);
178 }, ListOfObjectToListOfObject())));
179 return ListOfList()._check(tests);
180 };
181 dart.fn(unicode_tests._expandTestPairs, VoidToListOfList());
182 dart.defineLazy(unicode_tests, {
183 get UNICODE_TESTS() {
184 return unicode_tests._expandTestPairs();
185 }
186 });
187 // Exports:
188 exports.streamed_conversion_json_utf8_encode_test = streamed_conversion_json_u tf8_encode_test;
189 exports.json_unicode_tests = json_unicode_tests;
190 exports.unicode_tests = unicode_tests;
191 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698