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

Unified Diff: tests/corelib/collection_to_string_test.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/co19/co19-runtime.status ('k') | tests/corelib/math_parse_double_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/collection_to_string_test.dart
diff --git a/tests/corelib/collection_to_string_test.dart b/tests/corelib/collection_to_string_test.dart
index 77df1c8e962771a3a81c207f83712468cf40ff30..d0c879749fd29a99c9be781cfc42a9511a51aa58 100644
--- a/tests/corelib/collection_to_string_test.dart
+++ b/tests/corelib/collection_to_string_test.dart
@@ -6,12 +6,18 @@
* Tests for the toString methods on collections (including maps).
*/
+#library('collection_to_string');
+#import('dart:math', prefix: 'Math');
+
// TODO(jjb): seed random number generator when API allows it
final int NUM_TESTS = 300;
final int MAX_COLLECTION_SIZE = 7;
+Math.Random rand;
+
main() {
+ rand = new Math.Random();
smokeTest();
exactTest();
inexactTest();
@@ -124,7 +130,7 @@ Object randomCollection(int size, StringBuffer stringRep, [bool exact]) {
*/
Object randomCollectionHelper(int size, bool exact, StringBuffer stringRep,
List beingMade) {
- double interfaceFrac = Math.random();
+ double interfaceFrac = rand.nextDouble();
if (exact) {
if (interfaceFrac < 1/3) {
@@ -261,7 +267,7 @@ Map populateRandomMap(int size, bool exact, StringBuffer stringRep,
Object randomElement(int size, bool exact, StringBuffer stringRep,
List beingMade) {
Object result;
- double elementTypeFrac = Math.random();
+ double elementTypeFrac = rand.nextDouble();
if (elementTypeFrac < 1/3) {
result = random(1000);
stringRep.add(result);
@@ -281,12 +287,12 @@ Object randomElement(int size, bool exact, StringBuffer stringRep,
/** Returns a random int on [0, max) */
int random(int max) {
- return (Math.random() * max).toInt();
+ return rand.nextInt(max);
}
/** Returns a random boolean value. */
bool randomBool() {
- return Math.random() < .5;
+ return rand.nextBool();
}
/** Returns the alphabetized characters in a string. */
« no previous file with comments | « tests/co19/co19-runtime.status ('k') | tests/corelib/math_parse_double_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698