0e6c8683e3
Closes #41922 Change-Id: I403ca031898c72f3edc0ca9c7434466c3510c53d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148800 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
38 lines
688 B
Dart
38 lines
688 B
Dart
// Copyright (c) 2020, 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.
|
|
|
|
bool _called = false;
|
|
|
|
String init(String val) {
|
|
if (!_called) {
|
|
_called = true;
|
|
throw new Exception();
|
|
}
|
|
return val;
|
|
}
|
|
|
|
class C {
|
|
static late String? s = init("lateValue");
|
|
}
|
|
|
|
main() {
|
|
throws(() {
|
|
C.s;
|
|
});
|
|
expect("lateValue", C.s);
|
|
}
|
|
|
|
expect(expected, actual) {
|
|
if (expected != actual) throw 'Expected $expected, actual $actual';
|
|
}
|
|
|
|
throws(void Function() f) {
|
|
try {
|
|
f();
|
|
} catch (_) {
|
|
return;
|
|
}
|
|
throw 'Expected exception';
|
|
}
|