Index: sdk/lib/_internal/compiler/implementation/lib/math_patch.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/lib/math_patch.dart b/sdk/lib/_internal/compiler/implementation/lib/math_patch.dart |
index b20276efa101c5aad9e728ab4130eaee1d78cc30..1c74daef012313176b7c73b364b541af978028db 100644 |
--- a/sdk/lib/_internal/compiler/implementation/lib/math_patch.dart |
+++ b/sdk/lib/_internal/compiler/implementation/lib/math_patch.dart |
@@ -54,6 +54,15 @@ class _Random implements Random { |
return JS("int", "(Math.random() * #) >>> 0", max); |
} |
+ int nextIntRange(int min, int max) { |
+ if (max < 0) throw new ArgumentError("negative max: $max"); |
+ if (min >= max) throw new ArgumentError("min is greater then or equal to max"); |
floitsch
2013/11/18 13:36:03
80 chars. And the error message should contain the
|
+ |
+ int range = max - min; |
+ range = nextInt(range); |
floitsch
2013/11/18 13:36:03
Don't reuse the variable (which is not a range).
I
|
+ return min + range; |
+ } |
+ |
/** |
* Generates a positive random floating point value uniformly distributed on |
* the range from 0.0, inclusive, to 1.0, exclusive. |