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

Side by Side Diff: pkg/dev_compiler/test/codegen_expected/expect.js

Issue 2413073002: Start cleaning up the HTML tests. (Closed)
Patch Set: Unfork expect.dart. Created 4 years, 2 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
1 define(['dart_sdk'], function(dart_sdk) { 1 define(['dart_sdk'], function(dart_sdk) {
2 'use strict'; 2 'use strict';
3 const core = dart_sdk.core; 3 const core = dart_sdk.core;
4 const dart = dart_sdk.dart; 4 const dart = dart_sdk.dart;
5 const dartx = dart_sdk.dartx; 5 const dartx = dart_sdk.dartx;
6 const expect = Object.create(null); 6 const expect = Object.create(null);
7 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.functionType(dart.void, [])))(); 7 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.functionType(dart.void, [])))();
8 let dynamicAnddynamicTobool = () => (dynamicAnddynamicTobool = dart.constFn(da rt.definiteFunctionType(core.bool, [dart.dynamic, dart.dynamic])))(); 8 let dynamicAnddynamicTobool = () => (dynamicAnddynamicTobool = dart.constFn(da rt.definiteFunctionType(core.bool, [dart.dynamic, dart.dynamic])))();
9 expect.Expect = class Expect extends core.Object { 9 expect.Expect = class Expect extends core.Object {
10 static _truncateString(string, start, end, length) { 10 static _truncateString(string, start, end, length) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (!dart.test(extraSet.isEmpty)) { 203 if (!dart.test(extraSet.isEmpty)) {
204 sb.write('\nExpected collection should not contain: '); 204 sb.write('\nExpected collection should not contain: ');
205 } 205 }
206 for (let val of extraSet) { 206 for (let val of extraSet) {
207 sb.write(dart.str`${val} `); 207 sb.write(dart.str`${val} `);
208 } 208 }
209 expect.Expect._fail(sb.toString()); 209 expect.Expect._fail(sb.toString());
210 } 210 }
211 static deepEquals(expected, actual) { 211 static deepEquals(expected, actual) {
212 if (dart.equals(expected, actual)) return; 212 if (dart.equals(expected, actual)) return;
213 if (core.List.is(expected) && core.List.is(actual)) { 213 if (typeof expected == 'string' && typeof actual == 'string') {
214 let n = dart.notNull(expected[dartx.length]) < dart.notNull(actual[dartx .length]) ? expected[dartx.length] : actual[dartx.length]; 214 expect.Expect.stringEquals(expected, actual);
215 for (let i = 0; i < dart.notNull(n); i++) { 215 } else if (core.Iterable.is(expected) && core.Iterable.is(actual)) {
216 expect.Expect.deepEquals(expected[dartx.get](i), actual[dartx.get](i)) ; 216 let expectedLength = expected[dartx.length];
217 let actualLength = actual[dartx.length];
218 let length = dart.notNull(expectedLength) < dart.notNull(actualLength) ? expectedLength : actualLength;
219 for (let i = 0; i < dart.notNull(length); i++) {
220 expect.Expect.deepEquals(expected[dartx.elementAt](i), actual[dartx.el ementAt](i));
217 } 221 }
218 if (expected[dartx.length] != actual[dartx.length]) { 222 if (expectedLength != actualLength) {
219 expect.Expect._fail('Expect.deepEquals(list length, ' + dart.str`expec ted: <${expected[dartx.length]}>, actual: <${actual[dartx.length]}>) ` + 'fails: Next element <' + dart.str`${dart.notNull(expected[dartx.length]) > dart.notNul l(n) ? expected[dartx.get](n) : actual[dartx.get](n)}>`); 223 let nextElement = (dart.notNull(expectedLength) > dart.notNull(length) ? expected : actual)[dartx.elementAt](length);
224 expect.Expect._fail('Expect.deepEquals(list length, ' + dart.str`expec ted: <${expectedLength}>, actual: <${actualLength}>) ` + dart.str`fails: Next el ement <${nextElement}>`);
220 } 225 }
221 } else if (core.Map.is(expected) && core.Map.is(actual)) { 226 } else if (core.Map.is(expected) && core.Map.is(actual)) {
222 for (let key of expected[dartx.keys]) { 227 for (let key of expected[dartx.keys]) {
223 if (!dart.test(actual[dartx.containsKey](key))) { 228 if (!dart.test(actual[dartx.containsKey](key))) {
224 expect.Expect._fail(dart.str`Expect.deepEquals(missing expected key: <${key}>) fails`); 229 expect.Expect._fail(dart.str`Expect.deepEquals(missing expected key: <${key}>) fails`);
225 } 230 }
226 expect.Expect.deepEquals(expected[dartx.get](key), actual[dartx.get](k ey)); 231 expect.Expect.deepEquals(expected[dartx.get](key), actual[dartx.get](k ey));
227 } 232 }
228 for (let key of actual[dartx.keys]) { 233 for (let key of actual[dartx.keys]) {
229 if (!dart.test(expected[dartx.containsKey](key))) { 234 if (!dart.test(expected[dartx.containsKey](key))) {
230 expect.Expect._fail(dart.str`Expect.deepEquals(unexpected key: <${ke y}>) fails`); 235 expect.Expect._fail(dart.str`Expect.deepEquals(unexpected key: <${ke y}>) fails`);
231 } 236 }
232 } 237 }
233 } else if (typeof expected == 'string' && typeof actual == 'string') {
234 let stringDifference = expect.Expect._stringDifference(expected, actual) ;
235 dart.assert(stringDifference != null);
236 expect.Expect._fail(dart.str`Expect.deepEquals(${stringDifference}) fail s.`);
237 } else { 238 } else {
238 expect.Expect._fail(dart.str`Expect.deepEquals(expected: <${expected}>, actual: <${actual}>) ` + "fails."); 239 expect.Expect._fail(dart.str`Expect.deepEquals(expected: <${expected}>, actual: <${actual}>) ` + "fails.");
239 } 240 }
240 } 241 }
241 static throws(f, check, reason) { 242 static throws(f, check, reason) {
242 if (check === void 0) check = null; 243 if (check === void 0) check = null;
243 if (reason === void 0) reason = null; 244 if (reason === void 0) reason = null;
244 let msg = reason == null ? "" : dart.str`(${reason})`; 245 let msg = reason == null ? "" : dart.str`(${reason})`;
245 if (!expect._Nullary.is(f)) { 246 if (!expect._Nullary.is(f)) {
246 expect.Expect._fail(dart.str`Expect.throws${msg}: Function f not callabl e with zero arguments`); 247 expect.Expect._fail(dart.str`Expect.throws${msg}: Function f not callabl e with zero arguments`);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 329 }
329 }; 330 };
330 dart.setSignature(expect.AssumeDynamic, { 331 dart.setSignature(expect.AssumeDynamic, {
331 constructors: () => ({new: dart.definiteFunctionType(expect.AssumeDynamic, [ ])}) 332 constructors: () => ({new: dart.definiteFunctionType(expect.AssumeDynamic, [ ])})
332 }); 333 });
333 // Exports: 334 // Exports:
334 return { 335 return {
335 expect: expect 336 expect: expect
336 }; 337 };
337 }); 338 });
OLDNEW
« no previous file with comments | « pkg/dev_compiler/test/codegen/minitest.dart ('k') | pkg/dev_compiler/test/codegen_expected/minitest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698