OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library trydart.test_case; | 5 library trydart.test_case; |
6 | 6 |
7 import 'dart:html' show | 7 import 'dart:html' show |
8 document; | 8 document; |
9 | 9 |
10 import 'dart:async'; | 10 import 'dart:async'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 * test: | 26 * test: |
27 * | 27 * |
28 * 1. Run setup synchronously. | 28 * 1. Run setup synchronously. |
29 * | 29 * |
30 * 2. Schedule a new (async) Future which runs validate followed by the next | 30 * 2. Schedule a new (async) Future which runs validate followed by the next |
31 * test's setup. | 31 * test's setup. |
32 * | 32 * |
33 * 3. Repeat step 2 until there are no more tests. | 33 * 3. Repeat step 2 until there are no more tests. |
34 * | 34 * |
35 * The purpose of this test is to simulate edits (during setup), and then let | 35 * The purpose of this test is to simulate edits (during setup), and then let |
36 * the the mutation observer to process the mutations followed by validation. | 36 * the mutation observer to process the mutations followed by validation. |
37 */ | 37 */ |
38 void runTests(List<TestCase> tests) { | 38 void runTests(List<TestCase> tests) { |
39 Completer completer = new Completer(); | 39 Completer completer = new Completer(); |
40 asyncTest(() => completer.future.then((_) { | 40 asyncTest(() => completer.future.then((_) { |
41 // Clear the DOM to work around a bug in test.dart. | 41 // Clear the DOM to work around a bug in test.dart. |
42 document.body.nodes.clear(); | 42 document.body.nodes.clear(); |
43 })); | 43 })); |
44 | 44 |
45 void iterateTests(Iterator<TestCase> iterator) { | 45 void iterateTests(Iterator<TestCase> iterator) { |
46 if (iterator.moveNext()) { | 46 if (iterator.moveNext()) { |
47 TestCase test = iterator.current; | 47 TestCase test = iterator.current; |
48 print('${test.description}\nSetup.'); | 48 print('${test.description}\nSetup.'); |
49 test.setup(); | 49 test.setup(); |
50 new Future(() { | 50 new Future(() { |
51 test.validate(); | 51 test.validate(); |
52 print('${test.description}\nDone.'); | 52 print('${test.description}\nDone.'); |
53 iterateTests(iterator); | 53 iterateTests(iterator); |
54 }); | 54 }); |
55 } else { | 55 } else { |
56 completer.complete(null); | 56 completer.complete(null); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 iterateTests(tests.iterator); | 60 iterateTests(tests.iterator); |
61 } | 61 } |
OLD | NEW |