summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@zancanaro.id.au>2015-06-01 00:25:19 +1000
committerCarlo Zancanaro <carlo@zancanaro.id.au>2015-06-01 00:25:19 +1000
commit7e1182355d54f0dc8461ce7df7c4aca8c40d2a92 (patch)
tree49f864ec8f584dd5a4cfb3d03e6201fad20e653c /src/main
parenta4b5a5f904fe9f21697cd8fc8998c7e6e86306af (diff)
Just some rearranging, renaming and clean-up
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/au/id/zancanaro/Generators.java16
-rw-r--r--src/main/java/au/id/zancanaro/Properties.java (renamed from src/main/java/au/id/zancanaro/PropertyTestRunner.java)6
-rw-r--r--src/main/java/au/id/zancanaro/PropertyError.java (renamed from src/main/java/au/id/zancanaro/PropertyTestError.java)4
-rw-r--r--src/main/java/au/id/zancanaro/annotations/Generator.java8
4 files changed, 13 insertions, 21 deletions
diff --git a/src/main/java/au/id/zancanaro/Generators.java b/src/main/java/au/id/zancanaro/Generators.java
index 852a290..e0927ff 100644
--- a/src/main/java/au/id/zancanaro/Generators.java
+++ b/src/main/java/au/id/zancanaro/Generators.java
@@ -22,14 +22,6 @@ public class Generators {
return integer(0, gens.length).flatMap(index -> gens[index]);
}
- public static Generator<Integer> integer() {
- return (random, size) -> integer(-size, size).generate(random, size);
- }
-
- public static Generator<Integer> natural() {
- return (random, size) -> integer(0, size).generate(random, size);
- }
-
public static Generator<Integer> integer(int lower, int upper) {
return (random, size) -> {
int value = lower + random.nextInt(upper - lower);
@@ -38,6 +30,14 @@ public class Generators {
};
}
+ public static Generator<Integer> integer() {
+ return (random, size) -> integer(-size, size).generate(random, size);
+ }
+
+ public static Generator<Integer> natural() {
+ return (random, size) -> integer(0, size).generate(random, size);
+ }
+
private static Iterable<RoseTree<Integer>> intShrinkingIterable(final int value, final int bound) {
return () -> new Iterator<RoseTree<Integer>>() {
int curr = value - bound;
diff --git a/src/main/java/au/id/zancanaro/PropertyTestRunner.java b/src/main/java/au/id/zancanaro/Properties.java
index ea36341..fab48f4 100644
--- a/src/main/java/au/id/zancanaro/PropertyTestRunner.java
+++ b/src/main/java/au/id/zancanaro/Properties.java
@@ -13,10 +13,10 @@ import java.lang.reflect.*;
import java.util.*;
-public class PropertyTestRunner extends BlockJUnit4ClassRunner {
+public class Properties extends BlockJUnit4ClassRunner {
private final Map<Type, Generator<Object>> generators = new HashMap<>();
- public PropertyTestRunner(Class<?> klass) throws InitializationError {
+ public Properties(Class<?> klass) throws InitializationError {
super(klass);
}
@@ -184,7 +184,7 @@ public class PropertyTestRunner extends BlockJUnit4ClassRunner {
}
;
} catch (Throwable ex) {
- throw new PropertyTestError(method.getName(), seed, shrink(tree, ex));
+ throw new PropertyError(method.getName(), seed, shrink(tree, ex));
}
}
}
diff --git a/src/main/java/au/id/zancanaro/PropertyTestError.java b/src/main/java/au/id/zancanaro/PropertyError.java
index afd614b..b2fb589 100644
--- a/src/main/java/au/id/zancanaro/PropertyTestError.java
+++ b/src/main/java/au/id/zancanaro/PropertyError.java
@@ -4,8 +4,8 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
-public class PropertyTestError extends AssertionError {
- public PropertyTestError(String methodName, long seed, ShrinkResult shrunk) {
+public class PropertyError extends AssertionError {
+ public PropertyError(String methodName, long seed, ShrinkResult shrunk) {
super(String.format("%s(%s)\n\tSeed: %s\n%s",
methodName, join(", ", shrunk.args),
seed,
diff --git a/src/main/java/au/id/zancanaro/annotations/Generator.java b/src/main/java/au/id/zancanaro/annotations/Generator.java
deleted file mode 100644
index 98e9446..0000000
--- a/src/main/java/au/id/zancanaro/annotations/Generator.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package au.id.zancanaro.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-@Target(ElementType.PARAMETER)
-public @interface Generator {
-}