OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Test that the secure random generator does not systematically generates | 5 // Test that the secure random generator does not systematically generates |
6 // duplicates. Note that this test is flaky by definition, since duplicates | 6 // duplicates. Note that this test is flaky by definition, since duplicates |
7 // can occur. They should be extremely rare, though. | 7 // can occur. They should be extremely rare, though. |
8 | 8 |
9 // Library tag to allow Dartium to run the test. | 9 // Library tag to allow Dartium to run the test. |
10 library random_secure; | 10 library random_secure; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 var cnt1 = 0; | 52 var cnt1 = 0; |
53 rng0 = new Random.secure(); | 53 rng0 = new Random.secure(); |
54 for (var i = 0; i < 32; i++) { | 54 for (var i = 0; i < 32; i++) { |
55 rng1 = new Random.secure(); | 55 rng1 = new Random.secure(); |
56 cnt0 += rng0.nextBool() ? 1 : 0; | 56 cnt0 += rng0.nextBool() ? 1 : 0; |
57 cnt1 += rng1.nextBool() ? 1 : 0; | 57 cnt1 += rng1.nextBool() ? 1 : 0; |
58 } | 58 } |
59 Expect.isTrue((cnt0 > 0) && (cnt0 < 32)); | 59 Expect.isTrue((cnt0 > 0) && (cnt0 < 32)); |
60 Expect.isTrue((cnt1 > 0) && (cnt1 < 32)); | 60 Expect.isTrue((cnt1 > 0) && (cnt1 < 32)); |
61 } | 61 } |
OLD | NEW |