From 7b1a783b749ab04ab8219ef28f9b1abb0ded6ca4 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Wed, 3 Jun 2015 14:32:07 +1000 Subject: Rename RoseTree to ShrinkTree (less confusing and more specific) --- .../java/au/id/zancanaro/javacheck/Generators.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/main/java/au/id/zancanaro/javacheck/Generators.java') diff --git a/src/main/java/au/id/zancanaro/javacheck/Generators.java b/src/main/java/au/id/zancanaro/javacheck/Generators.java index 4049149..5dee924 100644 --- a/src/main/java/au/id/zancanaro/javacheck/Generators.java +++ b/src/main/java/au/id/zancanaro/javacheck/Generators.java @@ -18,7 +18,7 @@ public final class Generators { public static Generator suchThat(Generator gen, Predicate predicate) { return (random, size) -> { - RoseTree result = gen.generate(random, size); + ShrinkTree result = gen.generate(random, size); if (predicate.test(result.getValue())) { return result.filter(predicate); } else { @@ -28,7 +28,7 @@ public final class Generators { } public static Generator noShrink(Generator gen) { - return (random, size) -> new RoseTree<>( + return (random, size) -> new ShrinkTree<>( gen.generate(random, size).getValue(), Collections.emptyList()); } @@ -49,15 +49,15 @@ public final class Generators { public static Generator bool() { return (random, size) -> random.nextBoolean() ? - new RoseTree<>(true, Collections.singletonList(new RoseTree<>(false, Collections.emptyList()))) : - new RoseTree<>(false, Collections.emptyList()); + new ShrinkTree<>(true, Collections.singletonList(new ShrinkTree<>(false, Collections.emptyList()))) : + new ShrinkTree<>(false, Collections.emptyList()); } public static Generator integer(int lower, int upper) { return (random, size) -> { int value = lower + random.nextInt(upper - lower); int bound = lower > 0 ? lower : (upper < 0 ? upper : 0); - return new RoseTree<>(value, intShrinkingIterable(value, bound)); + return new ShrinkTree<>(value, intShrinkingIterable(value, bound)); }; } @@ -69,8 +69,8 @@ public final class Generators { return sized(size -> integer(0, size)); } - private static Iterable> intShrinkingIterable(final int value, final int bound) { - return () -> new Iterator>() { + private static Iterable> intShrinkingIterable(final int value, final int bound) { + return () -> new Iterator>() { int curr = value - bound; @Override @@ -79,10 +79,10 @@ public final class Generators { } @Override - public RoseTree next() { + public ShrinkTree next() { int prevCurr = curr; curr = curr / 2; - return new RoseTree<>(value - prevCurr, intShrinkingIterable(value - prevCurr, bound)); + return new ShrinkTree<>(value - prevCurr, intShrinkingIterable(value - prevCurr, bound)); } }; } -- cgit v1.2.3