OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dartino 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.md file. | |
4 | |
5 /// Tests of fletch_test_suite.dart. | |
6 library fletch_tests.self_tests; | |
7 | |
8 import 'dart:async' show | |
9 Completer, | |
10 Future; | |
11 | |
12 import 'dart:convert' show | |
13 JSON; | |
14 | |
15 import 'package:expect/expect.dart' show | |
16 Expect; | |
17 | |
18 import 'messages.dart'; | |
19 | |
20 import 'fletch_test_suite.dart' as suite show print; | |
21 | |
22 /// Test sleeps for 3 seconds. | |
23 Future testSleepForThreeSeconds() async { | |
24 await new Future.delayed(const Duration(seconds: 3)); | |
25 } | |
26 | |
27 /// Always fails. | |
28 Future testAlwaysFails() async { | |
29 throw "This test always fails."; | |
30 } | |
31 | |
32 /// Never completes (should be skipped). | |
33 Future testNeverCompletes() => new Completer().future; | |
34 | |
35 /// Test that messages can be instantiated and printed. | |
36 Future testMessages() async { | |
37 void testMessage(Message message) { | |
38 String json = JSON.encode(message); | |
39 Expect.stringEquals('$message', '${new Message.fromJson(json)}'); | |
40 } | |
41 | |
42 testMessage(const InternalErrorMessage("arg1", "arg2")); | |
43 testMessage(const ListTests()); | |
44 testMessage(const ListTestsReply(const <String>[])); | |
45 testMessage(const RunTest("arg1")); | |
46 testMessage(const TimedOut("arg1")); | |
47 testMessage(const TestFailed("arg1", "arg2", "arg3")); | |
48 testMessage(const TestPassed("arg1")); | |
49 testMessage(const Info("message")); | |
50 testMessage(const TestStdoutLine("name", "line")); | |
51 } | |
52 | |
53 /// Test print method. | |
54 Future testPrint() async { | |
55 suite.print("Debug print from fletch_tests works."); | |
56 } | |
OLD | NEW |