OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 #library("dunit"); | 6 #library("dunit"); |
7 | 7 |
8 typedef void Test(); | 8 typedef void Test(); |
9 typedef TestResult SynchTest(); | 9 typedef TestResult SynchTest(); |
10 typedef Future<TestResult> AsynchTest(); | 10 typedef Future<TestResult> AsynchTest(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 print(" PASSED: ${passedTests}"); | 50 print(" PASSED: ${passedTests}"); |
51 print(" FAILED: ${failures}"); | 51 print(" FAILED: ${failures}"); |
52 print(" ERRORS: ${errors}"); | 52 print(" ERRORS: ${errors}"); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 List<SynchTest> _tests; | 56 List<SynchTest> _tests; |
57 } | 57 } |
58 | 58 |
59 interface TestResult { | 59 interface TestResult { |
60 String get testDescription(); | 60 String get testDescription; |
61 } | 61 } |
62 | 62 |
63 class PassedTest implements TestResult { | 63 class PassedTest implements TestResult { |
64 const PassedTest(String this._testDescription); | 64 const PassedTest(String this._testDescription); |
65 String get testDescription() => _testDescription; | 65 String get testDescription => _testDescription; |
66 final String _testDescription; | 66 final String _testDescription; |
67 String toString() => _testDescription; | 67 String toString() => _testDescription; |
68 } | 68 } |
69 | 69 |
70 class _ExceptionResult { | 70 class _ExceptionResult { |
71 const _ExceptionResult(String this._testDescription, var this._exception); | 71 const _ExceptionResult(String this._testDescription, var this._exception); |
72 | 72 |
73 String get testDescription() => _testDescription; | 73 String get testDescription => _testDescription; |
74 final String _testDescription; | 74 final String _testDescription; |
75 | 75 |
76 Object get exception() => _exception; | 76 Object get exception => _exception; |
77 final _exception; | 77 final _exception; |
78 } | 78 } |
79 | 79 |
80 class FailedTest extends _ExceptionResult implements TestResult { | 80 class FailedTest extends _ExceptionResult implements TestResult { |
81 FailedTest(String testDescription, var exception) : | 81 FailedTest(String testDescription, var exception) : |
82 super(testDescription, exception); | 82 super(testDescription, exception); |
83 | 83 |
84 String toString() => ">>> Test failure in ${_testDescription} " + | 84 String toString() => ">>> Test failure in ${_testDescription} " + |
85 "with:\n${exception}\n"; | 85 "with:\n${exception}\n"; |
86 } | 86 } |
(...skipping 23 matching lines...) Expand all Loading... |
110 tearDown(); | 110 tearDown(); |
111 return new TestError(description, x, stacktrace); | 111 return new TestError(description, x, stacktrace); |
112 } | 112 } |
113 }); | 113 }); |
114 } | 114 } |
115 | 115 |
116 abstract void registerTests(TestSuite suite); | 116 abstract void registerTests(TestSuite suite); |
117 void setUp() {} | 117 void setUp() {} |
118 void tearDown() {} | 118 void tearDown() {} |
119 } | 119 } |
OLD | NEW |