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

Side by Side Diff: tests/language/checked_mode_helper.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library checked_mode_helper; 5 library checked_mode_helper;
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 8
9 /// Returns `true` if the program is running in checked mode. 9 /// Returns `true` if the program is running in checked mode.
10 bool inCheckedMode() { 10 bool inCheckedMode() {
(...skipping 15 matching lines...) Expand all
26 checkNoDynamicTypeError(f, message); 26 checkNoDynamicTypeError(f, message);
27 } 27 }
28 } 28 }
29 29
30 /// Checks that a dynamic type error is thrown if and only if [f] is executed in 30 /// Checks that a dynamic type error is thrown if and only if [f] is executed in
31 /// checked mode. 31 /// checked mode.
32 void checkDynamicTypeError(f(), [String message]) { 32 void checkDynamicTypeError(f(), [String message]) {
33 message = message != null ? ': $message' : ''; 33 message = message != null ? ': $message' : '';
34 try { 34 try {
35 f(); 35 f();
36 Expect.isFalse(inCheckedMode(), 36 Expect.isFalse(
37 'Missing type error in checked mode$message.'); 37 inCheckedMode(), 'Missing type error in checked mode$message.');
38 } on TypeError catch (e) { 38 } on TypeError catch (e) {
39 Expect.isTrue(inCheckedMode(), 39 Expect.isTrue(inCheckedMode(), 'Unexpected type error in production mode.');
40 'Unexpected type error in production mode.');
41 } 40 }
42 } 41 }
43 42
44 /// Checks that no dynamic type error is thrown when [f] is executed regardless 43 /// Checks that no dynamic type error is thrown when [f] is executed regardless
45 /// of execution mode. 44 /// of execution mode.
46 void checkNoDynamicTypeError(f(), [String message]) { 45 void checkNoDynamicTypeError(f(), [String message]) {
47 message = message != null ? ': $message' : ''; 46 message = message != null ? ': $message' : '';
48 try { 47 try {
49 f(); 48 f();
50 } on TypeError catch (e) { 49 } on TypeError catch (e) {
51 String mode = inCheckedMode() ? 'checked mode' : 'production mode'; 50 String mode = inCheckedMode() ? 'checked mode' : 'production mode';
52 Expect.fail('Unexpected type error in $mode$message.'); 51 Expect.fail('Unexpected type error in $mode$message.');
53 } 52 }
54 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698