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 /// Tests that Isolate.spanUri completes with an error when the given URI | 5 /// Tests that Isolate.spanUri completes with an error when the given URI |
6 /// doesn't resolve to an existing resource. | 6 /// doesn't resolve to an existing resource. |
7 library test.isolate.spawn_uri_missing_test; | 7 library test.isolate.spawn_uri_missing_test; |
8 | 8 |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
11 import 'dart:async'; | 11 import 'dart:async'; |
12 | 12 |
13 import 'package:async_helper/async_helper.dart'; | 13 import 'package:async_helper/async_helper.dart'; |
14 | 14 |
15 const UNEXPECTED_MESSAGE = 'Created isolate from missing file.'; | 15 const UNEXPECTED_MESSAGE = 'Created isolate from missing file.'; |
16 | 16 |
17 Future doTest() { | 17 Future doTest() { |
18 return Isolate.spawnUri(Uri.base.resolve('no_such_file'), [], null) | 18 return Isolate |
| 19 .spawnUri(Uri.base.resolve('no_such_file'), [], null) |
19 .then((Isolate isolate) { | 20 .then((Isolate isolate) { |
20 throw UNEXPECTED_MESSAGE; | 21 throw UNEXPECTED_MESSAGE; |
21 }).catchError((error) { | 22 }).catchError((error) { |
22 if (error == UNEXPECTED_MESSAGE) throw error; | 23 if (error == UNEXPECTED_MESSAGE) throw error; |
23 print('An error was thrown as expected'); | 24 print('An error was thrown as expected'); |
24 return null; | 25 return null; |
25 }); | 26 }); |
26 } | 27 } |
27 | 28 |
28 main() { | 29 main() { |
29 asyncTest(doTest); | 30 asyncTest(doTest); |
30 } | 31 } |
OLD | NEW |