mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
Fixed the conditions of an assert causing the debug VM to crash when trying to load a library from an invalid path. Created copy of a previous deferred_import_t02.dart test from co19 as a regression test until deferred_import_t02.dart is reverted to the previous test.
Fixes #27201 R=zra@google.com Review URL: https://codereview.chromium.org/2537253002 .
This commit is contained in:
parent
88c5dd5745
commit
7e918f5b48
3 changed files with 78 additions and 2 deletions
|
@ -11008,8 +11008,8 @@ bool LibraryPrefix::LoadLibrary() const {
|
|||
Exceptions::PropagateError(Error::Cast(obj));
|
||||
}
|
||||
} else {
|
||||
// Another load request is in flight.
|
||||
ASSERT(deferred_lib.LoadRequested());
|
||||
// Another load request is in flight or previously failed.
|
||||
ASSERT(deferred_lib.LoadRequested() || deferred_lib.LoadFailed());
|
||||
}
|
||||
return false; // Load request not yet completed.
|
||||
}
|
||||
|
|
20
tests/language/vm/regress_27201_lib.dart
Normal file
20
tests/language/vm/regress_27201_lib.dart
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) 2016, 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 import_lib;
|
||||
|
||||
final foo = 1;
|
||||
var someVar = 3;
|
||||
var _privateVar;
|
||||
|
||||
int get someGetter => 2;
|
||||
|
||||
void set someSetter(int val) {}
|
||||
|
||||
int someFunc() => 0;
|
||||
|
||||
class SomeClass {
|
||||
}
|
||||
|
||||
typedef int Func(Object a);
|
56
tests/language/vm/regress_27201_test.dart
Normal file
56
tests/language/vm/regress_27201_test.dart
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 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 "package:expect/expect.dart";
|
||||
import "regress_27201_lib.dart" deferred as p;
|
||||
import "regress_27201_bad_lib_path.dart" deferred as q;
|
||||
|
||||
test_loaded() {
|
||||
try {
|
||||
p.someFunc();
|
||||
} catch (e) {
|
||||
Expect.fail("Should not be here");
|
||||
}
|
||||
try {
|
||||
p.someGetter;
|
||||
} catch (e) {
|
||||
Expect.fail("Should not be here");
|
||||
}
|
||||
try {
|
||||
p.someSetter = 1;
|
||||
} catch (e) {
|
||||
Expect.fail("Should not be here");
|
||||
}
|
||||
try {
|
||||
p.Func;
|
||||
} catch (e) {
|
||||
Expect.fail("Should not be here");
|
||||
}
|
||||
try {
|
||||
Expect.isTrue(p.loadLibrary() is Future);
|
||||
} catch (e) {
|
||||
Expect.fail("Should not be here");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
p.loadLibrary().then((v) {
|
||||
test_loaded();
|
||||
},
|
||||
onError: (e) {
|
||||
Expect.fail("Should have loaded library!");
|
||||
});
|
||||
|
||||
// Ensure bad library import is handled correctly.
|
||||
q.loadLibrary().then((v) {
|
||||
Expect.fail("Should have failed");
|
||||
},
|
||||
onError: (e) {
|
||||
Expect.throws(() => q.x);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in a new issue