cleaned up tests
This commit is contained in:
parent
8d018fc168
commit
13bf8e0888
@ -2,9 +2,10 @@
|
|||||||
A PushGP implementation in Haskell
|
A PushGP implementation in Haskell
|
||||||
|
|
||||||
## Tasks
|
## Tasks
|
||||||
* [ ] Do test-driven development on this one.
|
* [x] Do test-driven development on this one.
|
||||||
* [ ] Write tests for every function.
|
* [x] Write tests for every function.
|
||||||
* [ ] tests/ are just copied from make-grade, need to write for this project.
|
* [x] tests/ are just copied from make-grade, need to write for this project.
|
||||||
|
* [ ] Included examples of basic assertions, QuickCheck, Hspec, hspec-quickcheck.
|
||||||
|
|
||||||
## Design considerations
|
## Design considerations
|
||||||
The biggest design constraint is that for the exec stack (but not data stacks)
|
The biggest design constraint is that for the exec stack (but not data stacks)
|
||||||
|
@ -31,38 +31,38 @@ main = do
|
|||||||
let loadedState = loadProgram [IntGene 6, IntGene 6, StateFunc instructionIntAdd] emptyState
|
let loadedState = loadProgram [IntGene 6, IntGene 6, StateFunc instructionIntAdd] emptyState
|
||||||
assert ([12] == int (interpretExec loadedState)) putStrLn "Interpret test 2 pass"
|
assert ([12] == int (interpretExec loadedState)) putStrLn "Interpret test 2 pass"
|
||||||
|
|
||||||
let loadedState2 = loadProgram [BoolGene True, StateFunc instructionExecIf, Block [IntGene 5, IntGene 6], Block [IntGene 7, IntGene 8]] emptyState
|
let loadedState = loadProgram [BoolGene True, StateFunc instructionExecIf, Block [IntGene 5, IntGene 6], Block [IntGene 7, IntGene 8]] emptyState
|
||||||
assert ([6, 5] == int (interpretExec loadedState2)) putStrLn "execIf"
|
assert ([6, 5] == int (interpretExec loadedState)) putStrLn "execIf"
|
||||||
|
|
||||||
let loadedState3 = loadProgram [BoolGene False, StateFunc instructionExecIf, Block [IntGene 5, IntGene 6], Block [IntGene 7, IntGene 8]] emptyState
|
let loadedState = loadProgram [BoolGene False, StateFunc instructionExecIf, Block [IntGene 5, IntGene 6], Block [IntGene 7, IntGene 8]] emptyState
|
||||||
assert ([8, 7] == int (interpretExec loadedState3)) putStrLn "execIf"
|
assert ([8, 7] == int (interpretExec loadedState)) putStrLn "execIf"
|
||||||
|
|
||||||
let loadedState4 = loadProgram [BoolGene False, PlaceInput "in0", StateFunc instructionIntAdd] exampleState
|
let loadedState = loadProgram [BoolGene False, PlaceInput "in0", StateFunc instructionIntAdd] exampleState
|
||||||
assert ([3, 6, 3] == int (interpretExec loadedState4)) putStrLn "input map"
|
assert ([3, 6, 3] == int (interpretExec loadedState)) putStrLn "input map"
|
||||||
|
|
||||||
let loadedState5 = interpretExec $ loadProgram [StateFunc instructionExecDup, IntGene 2] emptyState
|
let loadedState = interpretExec $ loadProgram [StateFunc instructionExecDup, IntGene 2] emptyState
|
||||||
assert (int loadedState5 !! 0 == 2 && int loadedState5 !! 1 == 2) putStrLn "execDup"
|
assert (int loadedState !! 0 == 2 && int loadedState !! 1 == 2) putStrLn "execDup"
|
||||||
|
|
||||||
let loadedState6 = loadProgram [IntGene 2, Block [IntGene 4, IntGene 1, StateFunc instructionExecDoRange], StateFunc instructionIntAdd] emptyState
|
let loadedState = loadProgram [IntGene 2, Block [IntGene 4, IntGene 1, StateFunc instructionExecDoRange], StateFunc instructionIntAdd] emptyState
|
||||||
assert ([12] == int (interpretExec loadedState6)) putStrLn "execDoRange"
|
assert ([12] == int (interpretExec loadedState)) putStrLn "execDoRange"
|
||||||
|
|
||||||
let loadedState7 = loadProgram [IntGene 2, Block [IntGene 4, StateFunc instructionExecDoCount], StateFunc instructionIntAdd] emptyState
|
let loadedState = loadProgram [IntGene 2, Block [IntGene 4, StateFunc instructionExecDoCount], StateFunc instructionIntAdd] emptyState
|
||||||
assert ([8] == int (interpretExec loadedState7)) putStrLn "execDoCount"
|
assert ([8] == int (interpretExec loadedState)) putStrLn "execDoCount"
|
||||||
|
|
||||||
let loadedState8 = loadProgram [IntGene 2, Block [IntGene 4, StateFunc instructionExecDoTimes], IntGene 69] emptyState
|
let loadedState = loadProgram [IntGene 2, Block [IntGene 4, StateFunc instructionExecDoTimes], IntGene 69] emptyState
|
||||||
assert ([69, 69, 69, 69, 2] == int (interpretExec loadedState8)) putStrLn "execDoTimes"
|
assert ([69, 69, 69, 69, 2] == int (interpretExec loadedState)) putStrLn "execDoTimes"
|
||||||
|
|
||||||
let loadedState9 = loadProgram [BoolGene False, BoolGene True, BoolGene True, StateFunc instructionExecWhile, IntGene 70] emptyState
|
let loadedState = loadProgram [BoolGene False, BoolGene True, BoolGene True, StateFunc instructionExecWhile, IntGene 70] emptyState
|
||||||
assert ([70, 70] == int (interpretExec loadedState9)) putStrLn "execWhile"
|
assert ([70, 70] == int (interpretExec loadedState)) putStrLn "execWhile"
|
||||||
|
|
||||||
let loadedState10 = loadProgram [BoolGene False, BoolGene True, BoolGene True, StateFunc instructionExecDoWhile, IntGene 70] emptyState
|
let loadedState = loadProgram [BoolGene False, BoolGene True, BoolGene True, StateFunc instructionExecDoWhile, IntGene 70] emptyState
|
||||||
assert ([70, 70, 70] == int (interpretExec loadedState10)) putStrLn "execDoWhile"
|
assert ([70, 70, 70] == int (interpretExec loadedState)) putStrLn "execDoWhile"
|
||||||
|
|
||||||
let loadedState11 = loadProgram [BoolGene False, StateFunc instructionExecWhen, IntGene 71] emptyState
|
let loadedState = loadProgram [BoolGene False, StateFunc instructionExecWhen, IntGene 71] emptyState
|
||||||
assert (emptyState == interpretExec loadedState11) putStrLn "execWhen"
|
assert (emptyState == interpretExec loadedState) putStrLn "execWhen"
|
||||||
|
|
||||||
let loadedState12 = loadProgram [BoolGene True, StateFunc instructionExecWhen, IntGene 71] emptyState
|
let loadedState = loadProgram [BoolGene True, StateFunc instructionExecWhen, IntGene 71] emptyState
|
||||||
assert ([71] == int (interpretExec loadedState12)) putStrLn "execWhen"
|
assert ([71] == int (interpretExec loadedState)) putStrLn "execWhen"
|
||||||
|
|
||||||
hspec $ do
|
hspec $ do
|
||||||
describe "Prelude.read" $ do
|
describe "Prelude.read" $ do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user