c30af41b96
- Forward only kImportTag requests to DFE. This restores the current handling of a kScriptTag request when loading the kernel isolate in the simulators. - Mark dynamic_load_test as failing in the reload stress tests (reload fails to preserve library identity). Change-Id: Ibe6f0a3505b99736a38d566abf3b2151505d7a7e Reviewed-on: https://dart-review.googlesource.com/56706 Reviewed-by: Siva Annamalai <asiva@google.com>
82 lines
2.5 KiB
Dart
82 lines
2.5 KiB
Dart
// Copyright (c) 2018, 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.
|
|
|
|
import 'dart:async';
|
|
import 'dart:mirrors';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
main() async {
|
|
IsolateMirror isolate = currentMirrorSystem().isolate;
|
|
print(isolate);
|
|
|
|
LibraryMirror success =
|
|
await isolate.loadUri(Uri.parse("dynamic_load_success.dart"));
|
|
print(success);
|
|
InstanceMirror result = success.invoke(#advanceCounter, []);
|
|
print(result);
|
|
Expect.equals(1, result.reflectee);
|
|
result = success.invoke(#advanceCounter, []);
|
|
print(result);
|
|
Expect.equals(2, result.reflectee);
|
|
|
|
LibraryMirror success2 =
|
|
await isolate.loadUri(Uri.parse("dynamic_load_success.dart"));
|
|
print(success2);
|
|
Expect.equals(success, success2);
|
|
result = success2.invoke(#advanceCounter, []);
|
|
print(result);
|
|
Expect.equals(3, result.reflectee); // Same library, same state.
|
|
|
|
LibraryMirror math = await isolate.loadUri(Uri.parse("dart:math"));
|
|
result = math.invoke(#max, [3, 4]);
|
|
print(result);
|
|
Expect.equals(4, result.reflectee);
|
|
|
|
Future<LibraryMirror> bad_load = isolate.loadUri(Uri.parse("DOES_NOT_EXIST"));
|
|
var error;
|
|
try {
|
|
await bad_load;
|
|
} catch (e) {
|
|
error = e;
|
|
}
|
|
print(error);
|
|
Expect.isTrue(error.toString().contains("Cannot open file") ||
|
|
error.toString().contains("No such file or directory"));
|
|
Expect.isTrue(error.toString().contains("DOES_NOT_EXIST"));
|
|
|
|
Future<LibraryMirror> bad_load2 = isolate.loadUri(Uri.parse("dart:_builtin"));
|
|
var error2;
|
|
try {
|
|
await bad_load2;
|
|
} catch (e) {
|
|
error2 = e;
|
|
}
|
|
print(error2);
|
|
Expect.isTrue(error2.toString().contains("Cannot load"));
|
|
Expect.isTrue(error2.toString().contains("dart:_builtin"));
|
|
|
|
// Check error is not sticky.
|
|
LibraryMirror success3 =
|
|
await isolate.loadUri(Uri.parse("dynamic_load_success.dart"));
|
|
print(success3);
|
|
Expect.equals(success, success3);
|
|
result = success3.invoke(#advanceCounter, []);
|
|
print(result);
|
|
Expect.equals(4, result.reflectee); // Same library, same state.
|
|
|
|
Future<LibraryMirror> bad_load3 =
|
|
isolate.loadUri(Uri.parse("dynamic_load_error.dart"));
|
|
var error3;
|
|
try {
|
|
await bad_load3;
|
|
} catch (e) {
|
|
error3 = e;
|
|
}
|
|
print(error3);
|
|
Expect.isTrue(error3.toString().contains("library url expected") ||
|
|
error3.toString().contains("Error: Expected a String"));
|
|
Expect.isTrue(error3.toString().contains("dynamic_load_error.dart"));
|
|
}
|