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

Side by Side Diff: pkg/expect/lib/expect.dart

Issue 1370073002: Add Base64 codec to dart:convert. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix for dart2js Created 5 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
« no previous file with comments | « no previous file | sdk/lib/convert/base64.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This library contains an Expect class with static methods that can be used 6 * This library contains an Expect class with static methods that can be used
7 * for simple unit-tests. 7 * for simple unit-tests.
8 */ 8 */
9 library expect; 9 library expect;
10 10
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 /** 351 /**
352 * Calls the function [f] and verifies that it throws an exception. 352 * Calls the function [f] and verifies that it throws an exception.
353 * The optional [check] function can provide additional validation 353 * The optional [check] function can provide additional validation
354 * that the correct exception is being thrown. For example, to check 354 * that the correct exception is being thrown. For example, to check
355 * the type of the exception you could write this: 355 * the type of the exception you could write this:
356 * 356 *
357 * Expect.throws(myThrowingFunction, (e) => e is MyException); 357 * Expect.throws(myThrowingFunction, (e) => e is MyException);
358 */ 358 */
359 static void throws(void f(), 359 static void throws(void f(),
360 [_CheckExceptionFn check = null, 360 [bool check(exception) = null,
361 String reason = null]) { 361 String reason = null]) {
362 String msg = reason == null ? "" : "($reason)"; 362 String msg = reason == null ? "" : "($reason)";
363 if (f is! _Nullary) { 363 if (f is! _Nullary) {
364 // Only throws from executing the funtion body should count as throwing. 364 // Only throws from executing the funtion body should count as throwing.
365 // The failure to even call `f` should throw outside the try/catch. 365 // The failure to even call `f` should throw outside the try/catch.
366 _fail("Expect.throws$msg: Function f not callable with zero arguments"); 366 _fail("Expect.throws$msg: Function f not callable with zero arguments");
367 } 367 }
368 try { 368 try {
369 f(); 369 f();
370 } catch (e, s) { 370 } catch (e, s) {
(...skipping 10 matching lines...) Expand all
381 static String _getMessage(String reason) 381 static String _getMessage(String reason)
382 => (reason == null) ? "" : ", '$reason'"; 382 => (reason == null) ? "" : ", '$reason'";
383 383
384 static void _fail(String message) { 384 static void _fail(String message) {
385 throw new ExpectException(message); 385 throw new ExpectException(message);
386 } 386 }
387 } 387 }
388 388
389 bool _identical(a, b) => identical(a, b); 389 bool _identical(a, b) => identical(a, b);
390 390
391 typedef bool _CheckExceptionFn(exception);
392 typedef _Nullary(); // Expect.throws argument must be this type. 391 typedef _Nullary(); // Expect.throws argument must be this type.
393 392
394 class ExpectException implements Exception { 393 class ExpectException implements Exception {
395 ExpectException(this.message); 394 ExpectException(this.message);
396 String toString() => message; 395 String toString() => message;
397 String message; 396 String message;
398 } 397 }
399 398
400 /// Annotation class for testing of dart2js. Use this as metadata on method 399 /// Annotation class for testing of dart2js. Use this as metadata on method
401 /// declarations to disable inlining of the annotated method. 400 /// declarations to disable inlining of the annotated method.
(...skipping 15 matching lines...) Expand all
417 const TrustTypeAnnotations(); 416 const TrustTypeAnnotations();
418 } 417 }
419 418
420 /// Annotation class for testing of dart2js. Use this as metadata on method 419 /// Annotation class for testing of dart2js. Use this as metadata on method
421 /// declarations to disable closed world assumptions on parameters, effectively 420 /// declarations to disable closed world assumptions on parameters, effectively
422 /// assuming that the runtime arguments could be any value. Note that the 421 /// assuming that the runtime arguments could be any value. Note that the
423 /// constraints due to [TrustTypeAnnotations] still apply. 422 /// constraints due to [TrustTypeAnnotations] still apply.
424 class AssumeDynamic { 423 class AssumeDynamic {
425 const AssumeDynamic(); 424 const AssumeDynamic();
426 } 425 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/convert/base64.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698