| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 87 | 87 |
| 88 class TestError extends _ExceptionResult implements TestResult { | 88 class TestError extends _ExceptionResult implements TestResult { |
| 89 TestError(String testDescription, var exception) : | 89 TestError(String testDescription, var exception, var this.stacktrace) : |
| 90 super(testDescription, exception); | 90 super(testDescription, exception); |
| 91 | 91 |
| 92 String toString() => ">>> Test error caught in " + | 92 String toString() => ">>> Test error caught in " + |
| 93 "${_testDescription} with:\n${exception}\n"; | 93 "${_testDescription} with:\n${exception}\n$stacktrace\n"; |
| 94 |
| 95 var stacktrace; |
| 94 } | 96 } |
| 95 | 97 |
| 96 class TestClass { | 98 class TestClass { |
| 97 void register(String description, Function test, TestSuite suite) { | 99 void register(String description, Function test, TestSuite suite) { |
| 98 suite._registerTest(TestResult _() { | 100 suite._registerTest(TestResult _() { |
| 99 setUp(); | 101 setUp(); |
| 100 try { | 102 try { |
| 101 test(); | 103 test(); |
| 102 tearDown(); | 104 tearDown(); |
| 103 return new PassedTest(description); | 105 return new PassedTest(description); |
| 104 } catch (ExpectException x) { | 106 } catch (ExpectException x) { |
| 105 tearDown(); | 107 tearDown(); |
| 106 return new FailedTest(description, x); | 108 return new FailedTest(description, x); |
| 107 } catch (var x) { | 109 } catch (var x, var stacktrace) { |
| 108 tearDown(); | 110 tearDown(); |
| 109 return new TestError(description, x); | 111 return new TestError(description, x, stacktrace); |
| 110 } | 112 } |
| 111 }); | 113 }); |
| 112 } | 114 } |
| 113 | 115 |
| 114 abstract void registerTests(TestSuite suite); | 116 abstract void registerTests(TestSuite suite); |
| 115 void setUp() {} | 117 void setUp() {} |
| 116 void tearDown() {} | 118 void tearDown() {} |
| 117 } | 119 } |
| OLD | NEW |