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.'; | |
16 | |
15 Future doTest() { | 17 Future doTest() { |
16 return Isolate.spawnUri(Uri.base.resolve('no_such_file'), [], null) | 18 return Isolate.spawnUri(Uri.base.resolve('no_such_file'), [], null) |
17 .then((Isolate isolate) { | 19 .then((Isolate isolate) { |
18 throw 'Created isolate from missing file'; | 20 throw UNEXPECTED_MESSAGE; |
19 }).catchError((error) { | 21 }).catchError((error) { |
22 if (error == UNEXPECTED_MESSAGE) throw error; | |
20 print('An error was thrown as expected'); | 23 print('An error was thrown as expected'); |
21 return null; | 24 return null; |
22 }); | 25 }); |
Lasse Reichstein Nielsen
2014/05/27 12:09:15
This seem overly complicated. Try this:
return
ahe
2014/05/27 13:31:27
We talked about this, and I was surprised that it
| |
23 } | 26 } |
24 | 27 |
25 main() { | 28 main() { |
26 asyncTest(doTest); | 29 asyncTest(doTest); |
27 } | 30 } |
OLD | NEW |