cabal co-exists beside Makefile
This commit is contained in:
parent
86fc353738
commit
cef2dc79a7
105
HushGP.cabal
Normal file
105
HushGP.cabal
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
cabal-version: 3.4
|
||||||
|
-- The cabal-version field refers to the version of the .cabal specification,
|
||||||
|
-- and can be different from the cabal-install (the tool) version and the
|
||||||
|
-- Cabal (the library) version you are using. As such, the Cabal (the library)
|
||||||
|
-- version used must be equal or greater than the version stated in this field.
|
||||||
|
-- Starting from the specification version 2.2, the cabal-version field must be
|
||||||
|
-- the first thing in the cabal file.
|
||||||
|
|
||||||
|
-- The name of the package.
|
||||||
|
name: HushGP
|
||||||
|
|
||||||
|
-- The package version.
|
||||||
|
-- PVP summary: +-+------- breaking API changes
|
||||||
|
-- | | +----- non-breaking API additions
|
||||||
|
-- | | | +--- code changes with no API change
|
||||||
|
version: 0.1.0.0
|
||||||
|
|
||||||
|
-- A short (one-line) description of the package.
|
||||||
|
synopsis: A PushGP implementation in Haskell.
|
||||||
|
|
||||||
|
-- The package author(s).
|
||||||
|
author: Taylor
|
||||||
|
|
||||||
|
-- An email address to which users can send suggestions, bug reports, and patches.
|
||||||
|
maintainer: behindthebrain@zoho.eu
|
||||||
|
|
||||||
|
category: Data
|
||||||
|
build-type: Simple
|
||||||
|
|
||||||
|
common warnings
|
||||||
|
ghc-options: -Wall
|
||||||
|
|
||||||
|
library
|
||||||
|
-- Import common warning flags.
|
||||||
|
import: warnings
|
||||||
|
|
||||||
|
-- Modules exported by the library.
|
||||||
|
exposed-modules: Push, GP
|
||||||
|
|
||||||
|
-- Modules included in this library but not exported.
|
||||||
|
-- other-modules:
|
||||||
|
|
||||||
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
|
-- other-extensions:
|
||||||
|
|
||||||
|
-- Other library packages from which modules are imported.
|
||||||
|
build-depends:
|
||||||
|
base ^>=4.18.2.1, containers
|
||||||
|
|
||||||
|
-- Directories containing source files.
|
||||||
|
hs-source-dirs: src
|
||||||
|
|
||||||
|
-- Base language which the package is written in.
|
||||||
|
default-language: GHC2021
|
||||||
|
|
||||||
|
executable HushGP
|
||||||
|
-- Import common warning flags.
|
||||||
|
import: warnings
|
||||||
|
|
||||||
|
-- .hs or .lhs file containing the Main module.
|
||||||
|
main-is: Main.hs
|
||||||
|
|
||||||
|
-- Modules included in this executable, other than Main.
|
||||||
|
-- other-modules:
|
||||||
|
|
||||||
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
|
-- other-extensions:
|
||||||
|
|
||||||
|
-- Other library packages from which modules are imported.
|
||||||
|
build-depends:
|
||||||
|
base ^>=4.18.2.1,
|
||||||
|
HushGP
|
||||||
|
|
||||||
|
-- Directories containing source files.
|
||||||
|
hs-source-dirs: app
|
||||||
|
|
||||||
|
-- Base language which the package is written in.
|
||||||
|
default-language: GHC2021
|
||||||
|
|
||||||
|
test-suite HushGP-test
|
||||||
|
-- Import common warning flags.
|
||||||
|
import: warnings
|
||||||
|
|
||||||
|
-- Base language which the package is written in.
|
||||||
|
default-language: GHC2021
|
||||||
|
|
||||||
|
-- Modules included in this executable, other than Main.
|
||||||
|
-- other-modules:
|
||||||
|
|
||||||
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
|
-- other-extensions:
|
||||||
|
|
||||||
|
-- The interface type and version of the test suite.
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
|
||||||
|
-- Directories containing source files.
|
||||||
|
hs-source-dirs: test
|
||||||
|
|
||||||
|
-- The entrypoint to the test suite.
|
||||||
|
main-is: Main.hs
|
||||||
|
|
||||||
|
-- Test dependencies.
|
||||||
|
build-depends:
|
||||||
|
base ^>=4.18.2.1,
|
||||||
|
HushGP
|
3
app/.ghci
Normal file
3
app/.ghci
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
:set stop :list
|
||||||
|
:set prompt "\ESC[1;34m%s \ESC[0;35mλ>\ESC[m "
|
||||||
|
:load Main ../src/GP ../src/Push
|
5
app/Main.hs
Normal file
5
app/Main.hs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import GP
|
||||||
|
import Push
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do pure ()
|
3
test/.ghci
Normal file
3
test/.ghci
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
:set stop :list
|
||||||
|
:set prompt "\ESC[1;34m%s \ESC[0;35mλ>\ESC[m "
|
||||||
|
:load Main ../src/GP ../src/Push
|
26
test/Main.hs
Normal file
26
test/Main.hs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import Control.Exception (assert)
|
||||||
|
import GP
|
||||||
|
import Push
|
||||||
|
|
||||||
|
intTestFunc :: String -> [Int] -> [Gene] -> State -> IO ()
|
||||||
|
intTestFunc name goal genome startState =
|
||||||
|
let state = loadProgram genome startState
|
||||||
|
in assert (goal == int (interpretExec state)) putStrLn (name ++ " passed test.")
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
intTestFunc "instructionIntAdd" [8] [GeneInt 6, GeneInt 2, StateFunc instructionIntAdd] emptyState
|
||||||
|
intTestFunc "instructionIntSub" [4] [GeneInt 6, GeneInt 2, StateFunc instructionIntSub] emptyState
|
||||||
|
intTestFunc "instructionIntMul" [12] [GeneInt 6, GeneInt 2, StateFunc instructionIntMul] emptyState
|
||||||
|
intTestFunc "instructionIntDiv" [3] [GeneInt 6, GeneInt 2, StateFunc instructionIntDiv] emptyState
|
||||||
|
intTestFunc "instructionExecIf" [6, 5] [GeneBool True, StateFunc instructionExecIf, Block [GeneInt 5, GeneInt 6], Block [GeneInt 7, GeneInt 8]] emptyState
|
||||||
|
intTestFunc "instructionExecDup" [8] [StateFunc instructionExecDup, GeneInt 4, StateFunc instructionIntAdd] emptyState
|
||||||
|
intTestFunc "instructionExecDoRange" [12] [GeneInt 2, Block [GeneInt 4, GeneInt 1, StateFunc instructionExecDoRange], StateFunc instructionIntAdd] emptyState
|
||||||
|
intTestFunc "instructionExecDoCount" [8] [GeneInt 2, Block [GeneInt 4, StateFunc instructionExecDoCount], StateFunc instructionIntAdd] emptyState
|
||||||
|
intTestFunc "instructionIntAdd" [69, 69, 69, 69, 2] [GeneInt 2, Block [GeneInt 4, StateFunc instructionExecDoTimes], GeneInt 69] emptyState
|
||||||
|
intTestFunc "instructionExecDoTimes" [70, 70] [GeneBool False, GeneBool True, GeneBool True, StateFunc instructionExecWhile, GeneInt 70] emptyState
|
||||||
|
intTestFunc "instructionExecWhile" [70, 70, 70] [GeneBool False, GeneBool True, GeneBool True, StateFunc instructionExecDoWhile, GeneInt 70] emptyState
|
||||||
|
intTestFunc "instructionExecDoWhile" [71] [GeneBool True, StateFunc instructionExecWhen, GeneInt 71] emptyState
|
||||||
|
|
||||||
|
let loadedState = loadProgram [GeneBool False, StateFunc instructionExecWhen, GeneInt 71] emptyState
|
||||||
|
assert (emptyState == interpretExec loadedState) putStrLn "instructionExecWhen passed test."
|
Loading…
x
Reference in New Issue
Block a user