blob: 49ff0ed9b364f987c70e43548ab6bc2c1a3f1f1d [file] [log] [blame]
// Copyright (c) 2022, 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.
/// @assertion Not all objects are supported as targets for weak references. The
/// WeakReference constructor will reject any object that is not supported as an
/// Expando key.
///
/// @description Check that WeakReference constructor rejects any object that is
/// not supported as an Expando key. Test Strings.
/// @author sgrekhov@unipro.ru
/// @issue 48264
import "../../../Utils/expect.dart";
main() {
Expect.throws(() {
WeakReference wr = WeakReference<String>("Lily was here");
print(wr.target);
});
Expect.throws(() {
String s = "Lily was here";
WeakReference wr = WeakReference(s);
print(wr.target);
});
}