From 285f1079b533a79311f33d2c8070a6180a67f5ed Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Sat, 6 Jun 2015 18:40:03 +1000 Subject: Make the initial state pass through to CommandList (for isValid()) --- src/main/java/au/id/zancanaro/javacheck/state/CommandList.java | 6 ++++-- .../java/au/id/zancanaro/javacheck/state/CommandListGenerator.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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 { private final List> commands; + private final S initialState; - public CommandList(List> commands) { + public CommandList(S initialState, List> commands) { + this.initialState = initialState; this.commands = new ArrayList<>(commands); } @@ -67,7 +69,7 @@ public class CommandList { } public boolean isValid() { - CommandResult result = CommandResult.success(null); + CommandResult result = CommandResult.success(initialState); for (GeneratedCommand 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 implements Generator> { 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); } } -- cgit v1.2.3