9b185051a9
The lazy static initializer returns null after throwing on the first use. Change-Id: I44fbb6f8af263dc5c813ed5dff2291fb27e48b4e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96984 Reviewed-by: Lasse R.H. Nielsen <lrn@google.com> Commit-Queue: Stephen Adams <sra@google.com>
28 lines
750 B
Dart
28 lines
750 B
Dart
// Copyright (c) 2019, 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.
|
|
|
|
// Test that `Random.secure()` throws `UnsupportedError` each time it fails.
|
|
|
|
import "package:expect/expect.dart";
|
|
import 'dart:math';
|
|
|
|
main() {
|
|
var result1 = getRandom();
|
|
var result2 = getRandom();
|
|
|
|
Expect.isNotNull(result1);
|
|
Expect.isNotNull(result2); // This fired for http://dartbug.com/36206
|
|
|
|
Expect.equals(result1 is Random, result2 is Random);
|
|
Expect.equals(result1 is UnsupportedError, result2 is UnsupportedError);
|
|
}
|
|
|
|
dynamic getRandom() {
|
|
try {
|
|
return Random.secure();
|
|
} catch (e) {
|
|
return e;
|
|
}
|
|
}
|