OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 rnd.nextInt with a seed generates the same sequence each time. | 5 // Test that rnd.nextInt with a seed generates the same sequence each time. |
6 | 6 |
7 // Library tag to allow Dartium to run the test. | 7 // Library tag to allow Dartium to run the test. |
8 library random_test; | 8 library random_test; |
9 | 9 |
10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ]; | 226 ]; |
227 for (var i = 0, m = 1; i < 75; i++) { | 227 for (var i = 0, m = 1; i < 75; i++) { |
228 Expect.equals(expectations[i], new Random(rawSeed * m).nextInt(65536)); | 228 Expect.equals(expectations[i], new Random(rawSeed * m).nextInt(65536)); |
229 Expect.equals( | 229 Expect.equals( |
230 negative_seed_expectations[i], new Random(rawSeed * -m).nextInt(65536)); | 230 negative_seed_expectations[i], new Random(rawSeed * -m).nextInt(65536)); |
231 m *= 2; | 231 m *= 2; |
232 } | 232 } |
233 // And test zero seed too. | 233 // And test zero seed too. |
234 Expect.equals(21391, new Random(0).nextInt(65536)); | 234 Expect.equals(21391, new Random(0).nextInt(65536)); |
235 } | 235 } |
OLD | NEW |