Skip to content
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

Merged
merged 1 commit into from
Aug 2, 2017
Merged

Conversation

boulter
Copy link
Contributor

@boulter boulter commented Aug 2, 2017

Useful for testing when you want to compare against known values.

@hs-lsong @pfarrel @jmagnarelli-hs

Copy link
Collaborator

@hs-lsong hs-lsong left a 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());
Copy link
Collaborator

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?

Copy link
Contributor Author

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());
Copy link
Collaborator

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.*;
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@hs-lsong
Copy link
Collaborator

hs-lsong commented Aug 2, 2017

LGTM.

@boulter boulter merged commit 67290cc into master Aug 2, 2017
@boulter boulter deleted the non-random-random branch August 2, 2017 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants