| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Make multitest copy and compile these files too. | |
| 6 // OtherScripts=isolate_create_error_helper_echo.dart | |
| 7 // OtherScripts=isolate_create_error_helper_syntax_error.dart | |
| 8 // OtherScripts=isolate_create_error_helper_lib.dart | |
| 9 // OtherScripts=isolate_create_error_helper_lib2.dart | |
| 10 // OtherScripts=isolate_create_error_helper_lib3.dart | |
| 11 // OtherScripts=isolate_create_error_helper_lib4.dart | |
| 12 // OtherScripts=isolate_create_error_helper_lib5.dart | |
| 13 | |
| 14 library isolate.create.error; | |
| 15 | |
| 16 import "dart:async"; | |
| 17 import "dart:isolate"; | |
| 18 import "package:expect/expect.dart"; | |
| 19 import "package:async_helper/async_helper.dart"; | |
| 20 | |
| 21 void main() { | |
| 22 asyncStart(); | |
| 23 isolateSpawnSuccess(); | |
| 24 isolateBadUriScheme(); /// 01: ok | |
| 25 isolateBadServerUri(); /// 02: ok | |
| 26 isolate404Uri(); /// 03: ok | |
| 27 isolateMissingFileUri(); /// 04: ok | |
| 28 isolateBadParse(); /// 05: ok | |
| 29 isolateNoMain(); /// 06: ok | |
| 30 isolateBadMain(); /// 07: ok | |
| 31 isolateBoolMain(); /// 08: ok | |
| 32 isolateFuncGetMain(); /// 09: ok | |
| 33 isolateFuncConstMain(); /// 10: ok | |
| 34 asyncEnd(); | |
| 35 } | |
| 36 | |
| 37 badSuccess(x) { | |
| 38 Expect.fail("Unexpected non-error: $x"); | |
| 39 } | |
| 40 | |
| 41 void isolateSpawnSuccess() { | |
| 42 // Canary case. If this case fails, either spawnUri isn't supported, or | |
| 43 // relative URI references don't work. | |
| 44 asyncStart(); | |
| 45 ReceivePort r = new ReceivePort(); | |
| 46 Future<Isolate> result = Isolate.spawnUri( | |
| 47 Uri.parse("isolate_create_error_helper_echo.dart"), ["echo"], r.sendPort); | |
| 48 result.then((Isolate isolate) { | |
| 49 r.first.then((m) { | |
| 50 asyncEnd(); | |
| 51 Expect.equals("echo", m); | |
| 52 }); | |
| 53 }); | |
| 54 } | |
| 55 | |
| 56 void isolateBadUriScheme() { | |
| 57 asyncStart(); | |
| 58 Future<Isolate> result = Isolate.spawnUri( | |
| 59 Uri.parse("wtf://example.com/NOT"), ["A"], null); | |
| 60 result.then(badSuccess, onError: (e) { | |
| 61 Expect.isTrue(e is IsolateSpawnException); | |
| 62 asyncEnd(); | |
| 63 }); | |
| 64 } | |
| 65 | |
| 66 void isolateBadServerUri() { | |
| 67 asyncStart(); | |
| 68 Future<Isolate> result = Isolate.spawnUri( | |
| 69 Uri.parse("http://nosuchserver-dartlang.org/index.html"), ["B"], null); | |
| 70 result.then(badSuccess, onError: (e) { | |
| 71 Expect.isTrue(e is IsolateSpawnException); | |
| 72 asyncEnd(); | |
| 73 }); | |
| 74 } | |
| 75 | |
| 76 void isolate404Uri() { | |
| 77 asyncStart(); | |
| 78 Future<Isolate> result = Isolate.spawnUri( | |
| 79 Uri.parse("http://dartlang.org/THISPAGENOTFOUND"), ["C"], null); | |
| 80 result.then(badSuccess, onError: (e) { | |
| 81 Expect.isTrue(e is IsolateSpawnException); | |
| 82 asyncEnd(); | |
| 83 }); | |
| 84 } | |
| 85 | |
| 86 void isolateMissingFileUri() { | |
| 87 asyncStart(); | |
| 88 Future<Isolate> result = Isolate.spawnUri( | |
| 89 Uri.parse("./THISFILENOTFOUND"), ["D"], null); | |
| 90 result.then(badSuccess, onError: (e) { | |
| 91 Expect.isTrue(e is IsolateSpawnException); | |
| 92 asyncEnd(); | |
| 93 }); | |
| 94 } | |
| 95 | |
| 96 void isolateBadParse() { | |
| 97 asyncStart(); | |
| 98 Future<Isolate> result = Isolate.spawnUri( | |
| 99 Uri.parse("./isolate_create_error_helper_syntax_error.dart"), | |
| 100 ["E"], null); | |
| 101 result.then(badSuccess, onError: (e) { | |
| 102 Expect.isTrue(e is IsolateSpawnException); | |
| 103 asyncEnd(); | |
| 104 }); | |
| 105 } | |
| 106 | |
| 107 void isolateNoMain() { | |
| 108 asyncStart(); | |
| 109 Future<Isolate> result = Isolate.spawnUri( | |
| 110 Uri.parse("./isolate_create_error_helper_lib.dart"), ["F"], null); | |
| 111 result.then(badSuccess, onError: (e) { | |
| 112 Expect.isTrue(e is IsolateSpawnException); | |
| 113 asyncEnd(); | |
| 114 }); | |
| 115 } | |
| 116 | |
| 117 void isolateBadMain() { | |
| 118 // Spawned library has a main method expecting three arguments. | |
| 119 asyncStart(); | |
| 120 Future<Isolate> result = Isolate.spawnUri( | |
| 121 Uri.parse("./isolate_create_error_helper_lib2.dart"), ["G"], null); | |
| 122 result.then(badSuccess, onError: (e) { | |
| 123 Expect.isTrue(e is IsolateSpawnException); | |
| 124 asyncEnd(); | |
| 125 }); | |
| 126 } | |
| 127 | |
| 128 void isolateBoolMain() { | |
| 129 // Spawned library has a bool main field. | |
| 130 asyncStart(); | |
| 131 Future<Isolate> result = Isolate.spawnUri( | |
| 132 Uri.parse("./isolate_create_error_helper_lib3.dart"), ["H"], null); | |
| 133 result.then(badSuccess, onError: (e) { | |
| 134 Expect.isTrue(e is IsolateSpawnException); | |
| 135 asyncEnd(); | |
| 136 }); | |
| 137 } | |
| 138 | |
| 139 void isolateFuncGetMain() { | |
| 140 // Spawned library has a lazy final main field with a function type. | |
| 141 asyncStart(); | |
| 142 Future<Isolate> result = Isolate.spawnUri( | |
| 143 Uri.parse("./isolate_create_error_helper_lib4.dart"), ["I"], null); | |
| 144 result.then(badSuccess, onError: (e) { | |
| 145 Expect.isTrue(e is IsolateSpawnException); | |
| 146 asyncEnd(); | |
| 147 }); | |
| 148 } | |
| 149 | |
| 150 void isolateFuncConstMain() { | |
| 151 // Spawned library has a const main field with a function type. | |
| 152 asyncStart(); | |
| 153 Future<Isolate> result = Isolate.spawnUri( | |
| 154 Uri.parse("./isolate_create_error_helper_lib5.dart"), ["J"], null); | |
| 155 result.then(badSuccess, onError: (e) { | |
| 156 Expect.isTrue(e is IsolateSpawnException); | |
| 157 asyncEnd(); | |
| 158 }); | |
| 159 } | |
| 160 | |
| 161 | |
| OLD | NEW |