From 7d18d781656fb1e530e46504d497c421e6e67911 Mon Sep 17 00:00:00 2001 From: Aearnus Date: Sat, 26 May 2018 13:22:22 -0700 Subject: [PATCH] Removed the executable from the library, moved it to the test (Version bump) --- app/Main.hs | 56 ---------------------------------------------------- package.yaml | 13 +----------- test/Spec.hs | 54 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 69 deletions(-) delete mode 100644 app/Main.hs diff --git a/app/Main.hs b/app/Main.hs deleted file mode 100644 index 5725df6..0000000 --- a/app/Main.hs +++ /dev/null @@ -1,56 +0,0 @@ -module Main where - -import DSL.SixtyFiveOhTwo -import Control.Monad.State -import qualified Data.ByteString as B -import Data.Int - -test1 :: Instruction -test1 = do - lda (Immediate 0xFF) - sta (ZeroPage 0x00) - lda (Immediate 0x00) - adc (Immediate 0x01) - cmp (ZeroPage 0x00) - bne (Relative (-0x03 :: Int8)) - - -test2f :: Instruction -test2f = do - lda (Immediate 0x10) - sta (Absolute 0x0200) - rts (Implied) - -test2 :: Instruction -test2 = do - define "accumulatorLoadNStore" test2f - call "accumulatorLoadNStore" - -test3f2 :: Instruction -test3f2 = replicateM_ 10 (inc (Accumulator)) - -test3f1 :: Instruction -test3f1 = do - lda (Immediate 0x02) - define "addIt" test3f2 - -test3 :: Instruction -test3 = do - define "loadIt" test3f1 - call "loadIt" - call "addIt" - -main :: IO () -main = do - putStrLn "test one: simple program" - putStrLn "========================" - print $ execState test1 emptyState - putStrLn "" - putStrLn "test two: simple function" - putStrLn "=========================" - print $ execState test2 emptyState - putStrLn "" - putStrLn "test two: nested function" - putStrLn "=========================" - print $ execState test3 emptyState - putStrLn "" diff --git a/package.yaml b/package.yaml index 25e76ca..801c1ad 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: sixty-five-oh-two -version: 1.0.0.0 +version: 1.1.0.0 github: "aearnus/sixty-five-oh-two" license: MIT author: "Tyler Limkemann" @@ -29,17 +29,6 @@ dependencies: library: source-dirs: src -executables: - sixty-five-oh-two-exe: - main: Main.hs - source-dirs: app - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - sixty-five-oh-two - tests: sixty-five-oh-two-test: main: Spec.hs diff --git a/test/Spec.hs b/test/Spec.hs index cd4753f..cba78aa 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,2 +1,54 @@ +import DSL.SixtyFiveOhTwo +import Control.Monad.State +import qualified Data.ByteString as B +import Data.Int + +test1 :: Instruction +test1 = do + lda (Immediate 0xFF) + sta (ZeroPage 0x00) + lda (Immediate 0x00) + adc (Immediate 0x01) + cmp (ZeroPage 0x00) + bne (Relative (-0x03 :: Int8)) + + +test2f :: Instruction +test2f = do + lda (Immediate 0x10) + sta (Absolute 0x0200) + rts (Implied) + +test2 :: Instruction +test2 = do + define "accumulatorLoadNStore" test2f + call "accumulatorLoadNStore" + +test3f2 :: Instruction +test3f2 = replicateM_ 10 (inc (Accumulator)) + +test3f1 :: Instruction +test3f1 = do + lda (Immediate 0x02) + define "addIt" test3f2 + +test3 :: Instruction +test3 = do + define "loadIt" test3f1 + call "loadIt" + call "addIt" + main :: IO () -main = putStrLn "Test suite not yet implemented" +main = do + putStrLn "test one: simple program" + putStrLn "========================" + print $ execState test1 emptyState + putStrLn "" + putStrLn "test two: simple function" + putStrLn "=========================" + print $ execState test2 emptyState + putStrLn "" + putStrLn "test two: nested function" + putStrLn "=========================" + print $ execState test3 emptyState + putStrLn ""