Skip to content

Commit

Permalink
Setup automatic builds and testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
V0ldek authored Apr 12, 2020
1 parent c6224f1 commit 2829b17
Show file tree
Hide file tree
Showing 17 changed files with 234 additions and 18 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Haskell CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-haskell@v1
with:
ghc-version: '8.6.4'
cabal-version: '3.0'
- name: Install dependencies
run: |
cabal update
cabal install --only-dependencies
- name: Build
run: |
cabal configure
cabal build
- name: Run tests
run: cabal test --test-show-details=always
24 changes: 13 additions & 11 deletions Harper.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 2505378526f03d2e56a7eafd10806ee763914cbb9712774dfc34e204ab9924e3
-- hash: 1292c5eacfd1a96f86a094038ec24eddeefd8228f9afd3eda0d7b94e16f50b6a

name: Harper
version: 0.1.0.0
Expand All @@ -26,7 +26,14 @@ source-repository head

library
exposed-modules:
Lib
ErrM
Harper.Abs
Harper.Engine
Harper.Engine.Comparable
Harper.Engine.Object
Harper.Lexer
Harper.Parser
Harper.Printer
other-modules:
Paths_Harper
hs-source-dirs:
Expand All @@ -41,14 +48,6 @@ library
executable Harper-exe
main-is: Main.hs
other-modules:
ErrM
Harper.Abs
Harper.Engine
Harper.Engine.Comparable
Harper.Engine.Object
Harper.Lexer
Harper.Parser
Harper.Printer
Paths_Harper
hs-source-dirs:
app
Expand All @@ -70,9 +69,12 @@ test-suite Harper-test
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
Harper
HUnit
, Harper
, array >=0.5 && <0.6
, base >=4.7 && <5
, containers >=0.6 && <0.7
, mtl >=2.2 && <2.3
, test-framework
, test-framework-hunit
default-language: Haskell2010
3 changes: 3 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ tests:
- -with-rtsopts=-N
dependencies:
- Harper
- HUnit
- test-framework
- test-framework-hunit
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions src/Lib.hs

This file was deleted.

14 changes: 14 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ packages:
extra-deps:
- alex-3.2.4@sha256:fcf1971fb513eab886072d1f705475f04fb65261a4d81361bede9d86056b474b,4054
- happy-1.19.9@sha256:f8c774230735a390c287b2980cfcd2703d24d8dde85a01ea721b7b4b4c82944f,4667
- HUnit-1.6.0.0@sha256:8014b27c884becd8041214a1ab263fa92244ca62700a911aff604a1047869298,1570
- call-stack-0.2.0@sha256:5ce796b78d5f964468ec6fe0717b4e7d0430817f37370c47b3e6b38e345b6643,1202
- test-framework-0.8.2.0@sha256:065a1a6f5d43cee0c01c9d7f1a9539c62661a91012c6314db31fbed1a512e9a1,6395
- test-framework-hunit-0.3.0.2@sha256:7fd007e9cb082cd64a2213a6d36acf057f7d6df6b5343a088e81b2b3a9a23545,1487
- ansi-terminal-0.10.3@sha256:e2fbcef5f980dc234c7ad8e2fa433b0e8109132c9e643bc40ea5608cd5697797,3226
- ansi-wl-pprint-0.6.9@sha256:f6fd6dbd4adcad0432bf75e5f5b19bb1deda00a1d8056faf18090026e577652d,2388
- extensible-exceptions-0.1.1.4@sha256:eb5fe684a7ffe8d1ed2ed6cdaec7dfb29efc780811ea7158a64edc2abc516f47,1205
- hostname-1.0@sha256:8203b6ecd14ca1ef12f73a471b0a6a4be3ad4568d8b84f2bc4bc9e0abb8c4153,813
- old-locale-1.0.0.7@sha256:fa998be2c7e00cd26a6e9075bea790caaf3932caa3e9497ad69bc20380dd6911,1071
- random-1.1@sha256:7b67624fd76ddf97c206de0801dc7e888097e9d572974be9b9ea6551d76965df,1777
- regex-posix-0.96.0.0@sha256:690d1366e9ea6df71ded3daf49ca3d53c63eda3f95937962299b2391824dc3b3,2531
- xml-1.3.14@sha256:edb7cf08e80013cab3f80e1cb1765cb8e4f0772cf5de8a50ba3bbdfa2ae61d8c,942
- colour-2.3.5@sha256:b27db0a3ad40d70bdbd8510a104269f8707592e80757a1abc66a22ba25e5a42f,1801
- regex-base-0.94.0.0@sha256:44aa95ca762294ffbb28cf0af9c567d93b5d2c56e4f38ce5385a257d899f968e,2253

# Override default flag values for local packages and extra-deps
# flags: {}
Expand Down
98 changes: 98 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,102 @@ packages:
sha256: 1f1d622f6e773e7a674da6364b755714c76c3fbb3c7a4e65deaf07242fc15211
original:
hackage: happy-1.19.9@sha256:f8c774230735a390c287b2980cfcd2703d24d8dde85a01ea721b7b4b4c82944f,4667
- completed:
hackage: HUnit-1.6.0.0@sha256:8014b27c884becd8041214a1ab263fa92244ca62700a911aff604a1047869298,1570
pantry-tree:
size: 878
sha256: 270a6f8d6ef23eba3a9a1697aa244576abb168d10cb8e4736cf4add2b09eb650
original:
hackage: HUnit-1.6.0.0@sha256:8014b27c884becd8041214a1ab263fa92244ca62700a911aff604a1047869298,1570
- completed:
hackage: call-stack-0.2.0@sha256:5ce796b78d5f964468ec6fe0717b4e7d0430817f37370c47b3e6b38e345b6643,1202
pantry-tree:
size: 500
sha256: 30cc02f50a7f660db6b5c4218b4021cd78cae90b135d893d55f32a1c8b1e1c08
original:
hackage: call-stack-0.2.0@sha256:5ce796b78d5f964468ec6fe0717b4e7d0430817f37370c47b3e6b38e345b6643,1202
- completed:
hackage: test-framework-0.8.2.0@sha256:065a1a6f5d43cee0c01c9d7f1a9539c62661a91012c6314db31fbed1a512e9a1,6395
pantry-tree:
size: 2050
sha256: 293bf84cc593f464d307c938e772455d0dbbef44baf0624d98e24f4910612702
original:
hackage: test-framework-0.8.2.0@sha256:065a1a6f5d43cee0c01c9d7f1a9539c62661a91012c6314db31fbed1a512e9a1,6395
- completed:
hackage: test-framework-hunit-0.3.0.2@sha256:7fd007e9cb082cd64a2213a6d36acf057f7d6df6b5343a088e81b2b3a9a23545,1487
pantry-tree:
size: 239
sha256: 355897b03e0320296f207350f8c8aba4071b673021aef726bac27e3ad0bbb2cc
original:
hackage: test-framework-hunit-0.3.0.2@sha256:7fd007e9cb082cd64a2213a6d36acf057f7d6df6b5343a088e81b2b3a9a23545,1487
- completed:
hackage: ansi-terminal-0.10.3@sha256:e2fbcef5f980dc234c7ad8e2fa433b0e8109132c9e643bc40ea5608cd5697797,3226
pantry-tree:
size: 1461
sha256: 02f05d52be3ffcf36c78876629cbab80b63420672685371aea4fd10e1c4aabb6
original:
hackage: ansi-terminal-0.10.3@sha256:e2fbcef5f980dc234c7ad8e2fa433b0e8109132c9e643bc40ea5608cd5697797,3226
- completed:
hackage: ansi-wl-pprint-0.6.9@sha256:f6fd6dbd4adcad0432bf75e5f5b19bb1deda00a1d8056faf18090026e577652d,2388
pantry-tree:
size: 472
sha256: a49f803a88dc2700cdce18f475525578e51964ae8bc9233d28331c66617711a8
original:
hackage: ansi-wl-pprint-0.6.9@sha256:f6fd6dbd4adcad0432bf75e5f5b19bb1deda00a1d8056faf18090026e577652d,2388
- completed:
hackage: extensible-exceptions-0.1.1.4@sha256:eb5fe684a7ffe8d1ed2ed6cdaec7dfb29efc780811ea7158a64edc2abc516f47,1205
pantry-tree:
size: 238
sha256: a3c019d3e48ea166f7865f83d369aa1c90ac4b19deaf7e2ddea33e96a2e70e32
original:
hackage: extensible-exceptions-0.1.1.4@sha256:eb5fe684a7ffe8d1ed2ed6cdaec7dfb29efc780811ea7158a64edc2abc516f47,1205
- completed:
hackage: hostname-1.0@sha256:8203b6ecd14ca1ef12f73a471b0a6a4be3ad4568d8b84f2bc4bc9e0abb8c4153,813
pantry-tree:
size: 212
sha256: 962f3607627035d8da35d0073170e75e736adcc6919a3d96669cbe28bf19468b
original:
hackage: hostname-1.0@sha256:8203b6ecd14ca1ef12f73a471b0a6a4be3ad4568d8b84f2bc4bc9e0abb8c4153,813
- completed:
hackage: old-locale-1.0.0.7@sha256:fa998be2c7e00cd26a6e9075bea790caaf3932caa3e9497ad69bc20380dd6911,1071
pantry-tree:
size: 263
sha256: 462ef15cb35164d585aa3860f717c9685fbf05578330490860abd544381d2e24
original:
hackage: old-locale-1.0.0.7@sha256:fa998be2c7e00cd26a6e9075bea790caaf3932caa3e9497ad69bc20380dd6911,1071
- completed:
hackage: random-1.1@sha256:7b67624fd76ddf97c206de0801dc7e888097e9d572974be9b9ea6551d76965df,1777
pantry-tree:
size: 637
sha256: 14a1b01728c5584e87c9fa00746a66e28ffd89dd2c0eabd334c8463953496e1b
original:
hackage: random-1.1@sha256:7b67624fd76ddf97c206de0801dc7e888097e9d572974be9b9ea6551d76965df,1777
- completed:
hackage: regex-posix-0.96.0.0@sha256:690d1366e9ea6df71ded3daf49ca3d53c63eda3f95937962299b2391824dc3b3,2531
pantry-tree:
size: 748
sha256: 0955278116618a3bafff70ce92b01a4b7f4eacc37fce012711a426ad199a3794
original:
hackage: regex-posix-0.96.0.0@sha256:690d1366e9ea6df71ded3daf49ca3d53c63eda3f95937962299b2391824dc3b3,2531
- completed:
hackage: xml-1.3.14@sha256:edb7cf08e80013cab3f80e1cb1765cb8e4f0772cf5de8a50ba3bbdfa2ae61d8c,942
pantry-tree:
size: 589
sha256: 6418f38f41819306abea7bc5b381f13fb96074d4fb0ecb27027136db8655bc65
original:
hackage: xml-1.3.14@sha256:edb7cf08e80013cab3f80e1cb1765cb8e4f0772cf5de8a50ba3bbdfa2ae61d8c,942
- completed:
hackage: colour-2.3.5@sha256:b27db0a3ad40d70bdbd8510a104269f8707592e80757a1abc66a22ba25e5a42f,1801
pantry-tree:
size: 1183
sha256: ff0f5e24e9f669ceedfcae4d11fd6c68820bbaa2e07ab277368946e9b0f6f8a4
original:
hackage: colour-2.3.5@sha256:b27db0a3ad40d70bdbd8510a104269f8707592e80757a1abc66a22ba25e5a42f,1801
- completed:
hackage: regex-base-0.94.0.0@sha256:44aa95ca762294ffbb28cf0af9c567d93b5d2c56e4f38ce5385a257d899f968e,2253
pantry-tree:
size: 483
sha256: 627ad9d564650590654720934224090a4e8fc3225e84a7fd1af83bc86b2d446a
original:
hackage: regex-base-0.94.0.0@sha256:44aa95ca762294ffbb28cf0af9c567d93b5d2c56e4f38ce5385a257d899f968e,2253
snapshots: []
Binary file added test/Spec.hi
Binary file not shown.
78 changes: 77 additions & 1 deletion test/Spec.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,78 @@
import Test.Framework
import Test.Framework.Providers.HUnit
import Test.HUnit

import Harper.Lexer
import Harper.Parser
import Harper.Engine
import Harper.Engine.Object
import ErrM

data TestProgram = TProg String Object

lexer = myLexer
parser = pProgram

issue1_sqr = TProg "\
\sqr n = n * n;\n\
\main = sqr 42;"
(PInt 1764)

issue1_partial = TProg "\
\f a b c d = (c ^ d / a) * 123 + b;\n\
\fun n = f n;\n\
\main = (fun 2) 420 6 4;"
(PInt 80124)

issue1_string = TProg "\
\main = \"abcd\";"
(PStr "abcd")

issue1_bool1 = TProg "\
\f n = 2 * n;\n\
\main = (f 42 == 84) and (f 2 <= f 4) and (f 2 < f 5) and (true and not false);"
(PBool True)

issue1_bool2 = TProg "\
\main = true or false;"
(PBool True)

issue1_bool3 = TProg "\
\main = true and false;"
(PBool False)

issue1_mod = TProg "\
\f n = 2 * n;\n\
\main = f 5 mod 3 == 1 and f 5 mod 3 != 2 and f 5 mod 3 > 0 and f 5 mod 3 >= 1;"
(PBool True)

issue1_lazy = TProg "\
\fun n = fun (n + 1);\n\
\main = true or (fun 42);"
(PBool True)

testProg :: TestProgram -> Test.HUnit.Test
testProg (TProg i o) = TestCase (assertEqual "Expected output" o run)
where run = let ts = lexer i
in case parser ts of
Bad e -> error e
Ok t -> fst $ runInterpreter t

tests = TestList [TestLabel "issue1_sqr" (testProg issue1_sqr),
TestLabel "issue1_partial" (testProg issue1_partial),
TestLabel "issue1_string" (testProg issue1_string),
TestLabel "issue1_bool1" (testProg issue1_bool1),
TestLabel "issue1_bool2" (testProg issue1_bool2),
TestLabel "issue1_bool3" (testProg issue1_bool3),
TestLabel "issue1_mod" (testProg issue1_mod),
TestLabel "issue1_lazy" (testProg issue1_lazy)
]

main :: IO ()
main = putStrLn "Test suite not yet implemented"
main = defaultMain $ hUnitTestToTests tests
Binary file added test/Spec.o
Binary file not shown.

0 comments on commit 2829b17

Please sign in to comment.