Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tests/lib/math/random_test.dart

Issue 12743005: Revert "Remove Expect from core library." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload (first upload failed). Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/lib/math/pi_test.dart ('k') | tests/lib/scalarlist/float32x4_list_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 a coin toss with Random.nextBool() is fair. 5 // Test that a coin toss with Random.nextBool() is fair.
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";
11 import 'dart:math'; 10 import 'dart:math';
12 11
13 main() { 12 main() {
14 var rnd = new Random(20130307); 13 var rnd = new Random(20130307);
15 // Make sure we do not break the random number generation. 14 // Make sure we do not break the random number generation.
16 var i = 0; 15 var i = 0;
17 Expect.equals( 0, rnd.nextInt(1 << ++i)); 16 Expect.equals( 0, rnd.nextInt(1 << ++i));
18 Expect.equals( 2, rnd.nextInt(1 << ++i)); 17 Expect.equals( 2, rnd.nextInt(1 << ++i));
19 Expect.equals( 7, rnd.nextInt(1 << ++i)); 18 Expect.equals( 7, rnd.nextInt(1 << ++i));
20 Expect.equals( 8, rnd.nextInt(1 << ++i)); 19 Expect.equals( 8, rnd.nextInt(1 << ++i));
(...skipping 22 matching lines...) Expand all
43 Expect.equals( 80223657, rnd.nextInt(1 << ++i)); 42 Expect.equals( 80223657, rnd.nextInt(1 << ++i));
44 Expect.equals( 142194155, rnd.nextInt(1 << ++i)); 43 Expect.equals( 142194155, rnd.nextInt(1 << ++i));
45 Expect.equals( 31792146, rnd.nextInt(1 << ++i)); 44 Expect.equals( 31792146, rnd.nextInt(1 << ++i));
46 Expect.equals(1042196170, rnd.nextInt(1 << ++i)); 45 Expect.equals(1042196170, rnd.nextInt(1 << ++i));
47 Expect.equals(1589656273, rnd.nextInt(1 << ++i)); 46 Expect.equals(1589656273, rnd.nextInt(1 << ++i));
48 Expect.equals(1547294578, rnd.nextInt(1 << ++i)); 47 Expect.equals(1547294578, rnd.nextInt(1 << ++i));
49 Expect.equals(32, i); 48 Expect.equals(32, i);
50 // If max is too large expect an ArgumentError. 49 // If max is too large expect an ArgumentError.
51 Expect.throws(() => rnd.nextInt((1 << i)+1), (e) => e is ArgumentError); 50 Expect.throws(() => rnd.nextInt((1 << i)+1), (e) => e is ArgumentError);
52 } 51 }
OLDNEW
« no previous file with comments | « tests/lib/math/pi_test.dart ('k') | tests/lib/scalarlist/float32x4_list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698