(defunmock-achieve-one(stategoal&key(remaining-goalsnil)(goal-stacknil)(opsnil))(declare(ignoreops))(dbg:mock-achieve-onegoal-stack"Mocking ~a"goal)(dbg:mock-achieve-onegoal-stack"Remaining goals: ~a"remaining-goals)(cond((member-*'badremaining-goals)(error'simple-error:format-arguments"Bad goal found!"))((eqgoal'bad)'(goodbads5))((eqgoal's1)nil)((eqgoal's2);; example of sneaking in dbg1 and returning a value(dbg1:mock-achieve-onegoal-stack"Saw s2, giving ~a"nil))((eqgoal's3)(appendstate'((executingb)s3)))((eqgoal's4)(appendstate'((executingc)s1s4)))))(define-testtest-achieve-all"Test only the achieve-all function.
It should continue to attempt goals until one works.";; Makes sure a single goal can be achieved.(assert-equality#'set-equalp'(s2s3(executingb))(achieve-all'(s2)'(s3):achieve-one#'mock-achieve-one));; Make sure the goal is removed from the remaining goals;; if it is not, the mock-achieve-one will signal an error.(assert-equality#'set-equalp'(goodbads5)(achieve-all'(mediums2)'(bads5):achieve-one#'mock-achieve-one));; This test checks that the second goal is attempted after the;; first one fails.(assert-equality#'set-equalp'(s1s4(executingc))(achieve-all'()'(s1s4):achieve-one#'mock-achieve-one));; Instant success, goal is subset of current state(assert-true(achieve-all'(s1s2s3(executinga)(executingb))'(s1s3(executinga)):achieve-one#'error)))