mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
582cec84f4
- Copies corelib_2/a* -> corelib/ - Copies language_2/ab* -> language/ - Copies lib_2/math/ -> lib/math/ - Copies standalone_2/a* -> standalone/ And also copies over and renames all of the status files in those directories. Then it migrates those tests to be static error free in NNBD. Finally, adds support to the test_runner for the new suites. Note that this review is split into multiple patchsets. The first patchset is a straight copy of the existing files. Then the later patchsets have the interesting changes. Change-Id: Icec2ff850a3aee30b653066ac184495d1e3814d0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125467 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Leaf Petersen <leafp@google.com> Reviewed-by: Alexander Thomas <athom@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
58 lines
1.7 KiB
Dart
58 lines
1.7 KiB
Dart
// Copyright (c) 2015, 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 the secure random generator does not systematically generates
|
|
// duplicates. Note that this test is flaky by definition, since duplicates
|
|
// can occur. They should be extremely rare, though.
|
|
|
|
import "package:expect/expect.dart";
|
|
import 'dart:math';
|
|
|
|
main() {
|
|
var results;
|
|
var rng0;
|
|
var rng1;
|
|
var checkInt = (max) {
|
|
var intVal0 = rng0.nextInt(max);
|
|
var intVal1 = rng1.nextInt(max);
|
|
if (max > (1 << 28)) {
|
|
Expect.isFalse(results.contains(intVal0));
|
|
results.add(intVal0);
|
|
Expect.isFalse(results.contains(intVal1));
|
|
results.add(intVal1);
|
|
}
|
|
};
|
|
results = [];
|
|
rng0 = new Random.secure();
|
|
for (var i = 0; i <= 32; i++) {
|
|
rng1 = new Random.secure();
|
|
checkInt(pow(2, 32));
|
|
checkInt(pow(2, 32 - i));
|
|
checkInt(1000000000);
|
|
}
|
|
var checkDouble = () {
|
|
var doubleVal0 = rng0.nextDouble();
|
|
var doubleVal1 = rng1.nextDouble();
|
|
Expect.isFalse(results.contains(doubleVal0));
|
|
results.add(doubleVal0);
|
|
Expect.isFalse(results.contains(doubleVal1));
|
|
results.add(doubleVal1);
|
|
};
|
|
results = [];
|
|
rng0 = new Random.secure();
|
|
for (var i = 0; i < 32; i++) {
|
|
rng1 = new Random.secure();
|
|
checkDouble();
|
|
}
|
|
var cnt0 = 0;
|
|
var cnt1 = 0;
|
|
rng0 = new Random.secure();
|
|
for (var i = 0; i < 32; i++) {
|
|
rng1 = new Random.secure();
|
|
cnt0 += rng0.nextBool() ? 1 : 0;
|
|
cnt1 += rng1.nextBool() ? 1 : 0;
|
|
}
|
|
Expect.isTrue((cnt0 > 0) && (cnt0 < 32));
|
|
Expect.isTrue((cnt1 > 0) && (cnt1 < 32));
|
|
}
|