| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // TODO(gram): | 5 // TODO(gram): |
| 6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. | 6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. |
| 7 // insufficient callbacks, because the timeout is controlled externally | 7 // insufficient callbacks, because the timeout is controlled externally |
| 8 // (test.dart?), and we would need to use a shorter timeout for the inner tests | 8 // (test.dart?), and we would need to use a shorter timeout for the inner tests |
| 9 // so the outer timeout doesn't fire. So I removed all such tests. | 9 // so the outer timeout doesn't fire. So I removed all such tests. |
| 10 // I'd like to revisit this at some point. | 10 // I'd like to revisit this at some point. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 test('testOne', () { | 132 test('testOne', () { |
| 133 var f = expectAsync0(() {}); | 133 var f = expectAsync0(() {}); |
| 134 _defer(protectAsync0(() { | 134 _defer(protectAsync0(() { |
| 135 _defer(protectAsync0(() => expect(false))); | 135 _defer(protectAsync0(() => expect(false))); |
| 136 expect(false); | 136 expect(false); |
| 137 })); | 137 })); |
| 138 }); | 138 }); |
| 139 test('testTwo', () { | 139 test('testTwo', () { |
| 140 _defer(expectAsync0(() {})); | 140 _defer(expectAsync0(() {})); |
| 141 }); | 141 }); |
| 142 } else if (testName == 'middle exception test') { |
| 143 test('testOne', () { expect(true, isTrue); }); |
| 144 test('testTwo', () { expect(true, isFalse); }); |
| 145 test('testThree', () { |
| 146 var done = expectAsync0((){}); |
| 147 _defer(() { |
| 148 expect(true, isTrue); |
| 149 done(); |
| 150 }); |
| 151 }); |
| 142 } | 152 } |
| 143 }); | 153 }); |
| 144 } | 154 } |
| 145 | 155 |
| 146 void nextTest(int testNum) { | 156 void nextTest(int testNum) { |
| 147 SendPort sport = spawnFunction(runTest); | 157 SendPort sport = spawnFunction(runTest); |
| 148 sport.call(tests[testNum]).then((msg) { | 158 sport.call(tests[testNum]).then((msg) { |
| 149 actual.add(msg); | 159 actual.add(msg); |
| 150 if (actual.length == expected.length) { | 160 if (actual.length == expected.length) { |
| 151 for (var i = 0; i < tests.length; i++) { | 161 for (var i = 0; i < tests.length; i++) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 163 'single failing test', | 173 'single failing test', |
| 164 'exception test', | 174 'exception test', |
| 165 'group name test', | 175 'group name test', |
| 166 'setup test', | 176 'setup test', |
| 167 'teardown test', | 177 'teardown test', |
| 168 'setup and teardown test', | 178 'setup and teardown test', |
| 169 'correct callback test', | 179 'correct callback test', |
| 170 'excess callback test', | 180 'excess callback test', |
| 171 'completion test', | 181 'completion test', |
| 172 'async exception test', | 182 'async exception test', |
| 173 'late exception test' | 183 'late exception test', |
| 184 'middle exception test' |
| 174 ]; | 185 ]; |
| 175 | 186 |
| 176 expected = [ | 187 expected = [ |
| 177 buildStatusString(1, 0, 0, tests[0]), | 188 buildStatusString(1, 0, 0, tests[0]), |
| 178 buildStatusString(0, 1, 0, tests[1], | 189 buildStatusString(0, 1, 0, tests[1], |
| 179 message: 'Expected: <5> but: was <4>.'), | 190 message: 'Expected: <5> but: was <4>.'), |
| 180 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), | 191 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), |
| 181 buildStatusString(2, 0, 0, 'a a::a b b'), | 192 buildStatusString(2, 0, 0, 'a a::a b b'), |
| 182 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'), | 193 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'), |
| 183 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'), | 194 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'), |
| 184 buildStatusString(1, 0, 0, 'a ${tests[6]}', 0, | 195 buildStatusString(1, 0, 0, 'a ${tests[6]}', 0, |
| 185 'setup', 'teardown'), | 196 'setup', 'teardown'), |
| 186 buildStatusString(1, 0, 0, tests[7], 1), | 197 buildStatusString(1, 0, 0, tests[7], 1), |
| 187 buildStatusString(0, 0, 1, tests[8], 1, | 198 buildStatusString(0, 0, 1, tests[8], 1, |
| 188 message: 'Callback called more times than expected (2 > 1).'), | 199 message: 'Callback called more times than expected (2 > 1).'), |
| 189 buildStatusString(1, 0, 0, tests[9], 10), | 200 buildStatusString(1, 0, 0, tests[9], 10), |
| 190 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), | 201 buildStatusString(0, 1, 0, tests[10], message: 'Caught error!'), |
| 191 buildStatusString(1, 0, 1, 'testOne', message: 'Callback called after alread
y being marked as done (1).:testTwo:') | 202 buildStatusString(1, 0, 1, 'testOne', message: 'Callback called after alread
y being marked as done (1).:testTwo:'), |
| 203 buildStatusString(2, 1, 0, 'testOne::testTwo:Expected: false but: was <true>
.:testThree') |
| 192 ]; | 204 ]; |
| 193 | 205 |
| 194 actual = []; | 206 actual = []; |
| 195 | 207 |
| 196 nextTest(0); | 208 nextTest(0); |
| 197 } | 209 } |
| 198 | 210 |
| OLD | NEW |