-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configurable random number generator #135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
while (index-- > 0) { | ||
it.next(); | ||
} | ||
return it.next(); | ||
} | ||
// number | ||
if (object instanceof Number) { | ||
return ThreadLocalRandom.current().nextLong(((Number) object).longValue()); | ||
return interpreter.getRandom().nextInt(((Number) object).intValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why changing long to int here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no nextLong()
that takes a bound in java.util.Random
. I figured random ints are probably big enough.
} | ||
// string | ||
if (object instanceof String) { | ||
try { | ||
return ThreadLocalRandom.current().nextLong(new BigDecimal((String) object).longValue()); | ||
return interpreter.getRandom().nextInt(new BigDecimal((String) object).intValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -2,27 +2,31 @@ | |||
|
|||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; | |||
import static org.mockito.Mockito.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import static org.mockito.Mockito.when should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our style is to always collapse imports for Mockito and a few other deps.
LGTM. |
Useful for testing when you want to compare against known values.
@hs-lsong @pfarrel @jmagnarelli-hs