OLD | NEW |
1 // Copyright (c) 201, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 201, 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 // VMOptions=--assert_initializer | 4 // VMOptions=--assert_initializer |
5 // | 5 // |
6 // Dart test program testing assert statements. | 6 // Dart test program testing assert statements. |
7 | 7 |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 | 9 |
10 class C { | 10 class C { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 Expect.identical(c1, const C.cc05(1, 2)); | 78 Expect.identical(c1, const C.cc05(1, 2)); |
79 Expect.identical(c1, const C.cc06(1, 2)); | 79 Expect.identical(c1, const C.cc06(1, 2)); |
80 Expect.identical(c1, const C.cc07(1, 2)); | 80 Expect.identical(c1, const C.cc07(1, 2)); |
81 Expect.identical(c1, const C.cc08(1, 2)); | 81 Expect.identical(c1, const C.cc08(1, 2)); |
82 Expect.identical(c1, const C.cc09(1, 2)); | 82 Expect.identical(c1, const C.cc09(1, 2)); |
83 Expect.identical(c1, const C.cc10(1, 2)); | 83 Expect.identical(c1, const C.cc10(1, 2)); |
84 Expect.identical(c1, const C.cc11(1, 2)); | 84 Expect.identical(c1, const C.cc11(1, 2)); |
85 } | 85 } |
86 | 86 |
87 void test(int x, int y) { | 87 void test(int x, int y) { |
88 bool assertionsEnabled = false; | 88 bool checkedMode = false; |
89 assert(assertionsEnabled = true); | 89 assert(checkedMode = true); |
90 | 90 |
91 bool Function(C Function()) doTest = (assertionsEnabled && x >= y) | 91 bool Function(C Function()) doTest = (checkedMode && x >= y) |
92 ? (f) { Expect.throws(f, (e) => e is AssertionError); } | 92 ? (f) { Expect.throws(f, (e) => e is AssertionError); } |
93 : (f) { Expect.equals(x, f().x); }; | 93 : (f) { Expect.equals(x, f().x); }; |
94 | 94 |
95 doTest(() => new C.c01(x, y)); | 95 doTest(() => new C.c01(x, y)); |
96 doTest(() => new C.c02(x, y)); | 96 doTest(() => new C.c02(x, y)); |
97 doTest(() => new C.c03(x, y)); | 97 doTest(() => new C.c03(x, y)); |
98 doTest(() => new C.c04(x, y)); | 98 doTest(() => new C.c04(x, y)); |
99 doTest(() => new C.c05(x, y)); | 99 doTest(() => new C.c05(x, y)); |
100 doTest(() => new C.c06(x, y)); | 100 doTest(() => new C.c06(x, y)); |
101 doTest(() => new C.c07(x, y)); | 101 doTest(() => new C.c07(x, y)); |
(...skipping 29 matching lines...) Expand all Loading... |
131 doTest(() => new C.fc04(x, y)); | 131 doTest(() => new C.fc04(x, y)); |
132 doTest(() => new C.fc05(x, y)); | 132 doTest(() => new C.fc05(x, y)); |
133 doTest(() => new C.fc06(x, y)); | 133 doTest(() => new C.fc06(x, y)); |
134 doTest(() => new C.fc07(x, y)); | 134 doTest(() => new C.fc07(x, y)); |
135 doTest(() => new C.fc08(x, y)); | 135 doTest(() => new C.fc08(x, y)); |
136 doTest(() => new C.fc09(x, y)); | 136 doTest(() => new C.fc09(x, y)); |
137 doTest(() => new C.fc10(x, y)); | 137 doTest(() => new C.fc10(x, y)); |
138 doTest(() => new C.fc11(x, y)); | 138 doTest(() => new C.fc11(x, y)); |
139 } | 139 } |
140 | 140 |
OLD | NEW |