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

Side by Side Diff: tests/language_strong/bool_check_test.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 bool typeChecksEnabled() { 7 bool typeChecksEnabled() {
8 try { 8 try {
9 var i = 42; 9 var i = 42;
10 String s = i; 10 String s = i;
11 } on TypeError catch (e) { 11 } on TypeError catch (e) {
12 return true; 12 return true;
13 } 13 }
14 return false; 14 return false;
15 } 15 }
16 16
17 bool assertionsEnabled() { 17 bool assertionsEnabled() {
18 try { 18 try {
19 assert(false); 19 assert(false);
20 return false; 20 return false;
21 } on AssertionError catch (e) { 21 } on AssertionError catch (e) {
22 return true; 22 return true;
23 } 23 }
24 return false; 24 return false;
25 } 25 }
26 26
27 final bool typeChecksOn = typeChecksEnabled(); 27 final bool typeChecksOn = typeChecksEnabled();
28 final bool assertionsOn = assertionsEnabled(); 28 final bool assertionsOn = assertionsEnabled();
29 29
30 ifExpr(e) { if (e) return true; else return false; } 30 ifExpr(e) {
31 if (e)
32 return true;
33 else
34 return false;
35 }
36
31 bool ifNull() => ifExpr(null); 37 bool ifNull() => ifExpr(null);
32 bool ifString() => ifExpr("true"); 38 bool ifString() => ifExpr("true");
33 39
34 main() { 40 main() {
35 print("type checks: $typeChecksOn"); 41 print("type checks: $typeChecksOn");
36 print("assertions: $assertionsOn"); 42 print("assertions: $assertionsOn");
37 43
38 if (typeChecksOn) { 44 if (typeChecksOn) {
39 Expect.throws(ifNull, (e) => e is AssertionError); 45 Expect.throws(ifNull, (e) => e is AssertionError);
40 } 46 }
41 if (assertionsOn && !typeChecksOn) { 47 if (assertionsOn && !typeChecksOn) {
42 Expect.throws(ifNull, (e) => e is AssertionError); 48 Expect.throws(ifNull, (e) => e is AssertionError);
43 } 49 }
44 if (!typeChecksOn && !assertionsOn) { 50 if (!typeChecksOn && !assertionsOn) {
45 Expect.identical(false, ifNull()); 51 Expect.identical(false, ifNull());
46 } 52 }
47 53
48 if (!typeChecksOn) { 54 if (!typeChecksOn) {
49 Expect.identical(false, ifString()); 55 Expect.identical(false, ifString());
50 } 56 }
51 if (typeChecksOn) { 57 if (typeChecksOn) {
52 Expect.throws(ifString, (e) => e is TypeError); 58 Expect.throws(ifString, (e) => e is TypeError);
53 } 59 }
54 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698