Chromium Code Reviews| Index: tests/isolate/isolate_create_error_test.dart |
| diff --git a/tests/isolate/isolate_create_error_test.dart b/tests/isolate/isolate_create_error_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..10e82c80911c0e1286c4cc93930c25fca3655e0e |
| --- /dev/null |
| +++ b/tests/isolate/isolate_create_error_test.dart |
| @@ -0,0 +1,136 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library isolate.create.error; |
| + |
| +import "dart:async"; |
| +import "dart:isolate"; |
| +import "package:expect/expect.dart"; |
| +import "package:async_helper/async_helper.dart"; |
| + |
| +void main() { |
| + asyncStart(); |
| + isolateBadUriScheme(); /// 01: ok |
| + isolateBadServerUri(); /// 02: ok |
| + isolate404Uri(); /// 03: ok |
| + isolateMissingFileUri(); /// 04: ok |
| + isolateBadParse(); /// 05: ok |
| + isolateNoMain(); /// 06: ok |
| + isolateBadMain(); /// 07: ok |
| + isolateBoolMain(); /// 08: ok |
| + isolateFuncGetMain(); /// 09: ok |
| + isolateFuncConstMain(); /// 10: ok |
| + asyncEnd(); |
| +} |
| + |
| +badSuccess(x) { |
| + print("Unexpected non-error: $x"); |
| +} |
| + |
| +void isolateBadUriScheme() { |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("wtf://example.com/NOT"), ["A"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
|
Søren Gjesse
2014/05/28 12:00:42
Add an expectation for e instead of print (in all
|
| + print("A: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolateBadServerUri() { |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("http://nosuchserver-dartlang.org/index.html"), ["B"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("B: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolate404Uri() { |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("http://dartlang.org/THISPAGENOTFOUND"), ["C"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("C: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolateMissingFileUri() { |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("./THISFILENOTFOUND"), ["D"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("D: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolateBadParse() { |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("./isolate_create_error_helper_syntax_error.dart"), |
| + ["E"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("E: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolateNoMain() { |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("./isolate_create_error_helper_lib.dart"), ["F"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("F: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolateBadMain() { |
| + // Spawned library has a main method expecting three arguments. |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("./isolate_create_error_helper_lib2.dart"), ["G"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("G: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolateBoolMain() { |
| + // Spawned library has a bool main field. |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("./isolate_create_error_helper_lib3.dart"), ["H"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("H: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolateFuncGetMain() { |
| + // Spawned library has a lazy final main field with a function type. |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("./isolate_create_error_helper_lib4.dart"), ["I"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("I: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void isolateFuncConstMain() { |
| + // Spawned library has a const main field with a function type. |
| + asyncStart(); |
| + Future<Isolate> result = Isolate.spawnUri( |
| + Uri.parse("./isolate_create_error_helper_lib5.dart"), ["J"], null); |
| + result.then(badSuccess, onError: (IsolateSpawnException e) { |
| + print("J: $e"); |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| + |