OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 // VMOptions=--enable_asserts | |
5 | |
6 // Dart test program testing assert statements. | |
7 | |
8 import "package:expect/expect.dart"; | |
9 | |
10 class AssertTest { | |
11 static test() { | |
12 try { | |
13 assert(false); | |
14 Expect.fail("Assertion 'false' didn't fail."); | |
15 } on AssertionError catch (error) { | |
16 Expect.isTrue(error.toString().contains("'false'")); | |
17 Expect.isTrue( | |
18 error.stackTrace.toString().contains("assert_test.dart:13:14")); | |
19 } | |
20 } | |
21 | |
22 static testClosure() { | |
23 try { | |
24 assert(() => false); | |
25 Expect.fail("Assertion '() => false' didn't fail."); | |
26 } on AssertionError catch (error) { | |
27 Expect.isTrue(error.toString().contains("'() => false'")); | |
28 Expect.isTrue( | |
29 error.stackTrace.toString().contains("assert_test.dart:24:14")); | |
30 } | |
31 } | |
32 | |
33 static testMain() { | |
34 test(); | |
35 testClosure(); | |
36 } | |
37 } | |
38 | |
39 main() { | |
40 AssertTest.testMain(); | |
41 } | |
OLD | NEW |