diff options
author | Carlo Zancanaro <carlo@zancanaro.id.au> | 2015-06-06 18:40:03 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@zancanaro.id.au> | 2015-06-06 18:40:03 +1000 |
commit | 285f1079b533a79311f33d2c8070a6180a67f5ed (patch) | |
tree | a2c533146592f57960c2ed03de7072106198b698 | |
parent | 84f0f216b4643601e4b8760d190b087bbce98bd4 (diff) |
Make the initial state pass through to CommandList (for isValid())
-rw-r--r-- | src/main/java/au/id/zancanaro/javacheck/state/CommandList.java | 6 | ||||
-rw-r--r-- | src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/au/id/zancanaro/javacheck/state/CommandList.java b/src/main/java/au/id/zancanaro/javacheck/state/CommandList.java index 05000f2..31fbc12 100644 --- a/src/main/java/au/id/zancanaro/javacheck/state/CommandList.java +++ b/src/main/java/au/id/zancanaro/javacheck/state/CommandList.java @@ -4,8 +4,10 @@ import java.util.*; public class CommandList<S> { private final List<GeneratedCommand<S, ?, ?>> commands; + private final S initialState; - public CommandList(List<GeneratedCommand<S, ?, ?>> commands) { + public CommandList(S initialState, List<GeneratedCommand<S, ?, ?>> commands) { + this.initialState = initialState; this.commands = new ArrayList<>(commands); } @@ -67,7 +69,7 @@ public class CommandList<S> { } public boolean isValid() { - CommandResult<S> result = CommandResult.success(null); + CommandResult<S> result = CommandResult.success(initialState); for (GeneratedCommand<S, ?, ?> generated : commands) { result = runAbstractCommand(generated, result.getState()); if (result.isFailed()) { diff --git a/src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java b/src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java index 1600f07..c5cda59 100644 --- a/src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java +++ b/src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java @@ -46,7 +46,7 @@ public class CommandListGenerator<S> implements Generator<CommandList<S>> { state = nextState(i, generatedCommand, state); } return ShrinkTree.combine(commandTrees, ShrinkTree::removeAndPromoteChildren) - .map(list -> new CommandList<>(list)) + .map(list -> new CommandList<>(initialState, list)) .filter(CommandList::isValid); } } |