Skip to content

Commit 8786609

Browse files
adamwespiserAdam Wespiser
authored andcommitted
Upgrade stack to lts-16.17, tests, minor fixes
1 parent 5a3b9c1 commit 8786609

File tree

11 files changed

+113
-112
lines changed

11 files changed

+113
-112
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ cabal.sandbox.config
77
output/*
88
*.hi
99
*.o
10+
scheme.cabal
11+
stack.yaml.lock

Build.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
{-# LANGUAGE OverloadedStrings, RankNTypes, ScopedTypeVariables, TypeApplications #-}
12
module Main where
23

3-
import Prelude hiding ((*>))
4+
import Prelude
45
import Development.Shake
56
import Development.Shake.FilePath
67

@@ -14,12 +15,12 @@ main = shakeArgs shakeOptions $ do
1415
let targets = ["output" </> (f -<.> "wiki") | f <- files]
1516
need targets
1617

17-
"output/scheme.html" *> \out -> do
18+
"output/scheme.html" %> \out -> do
1819
need ["resources/page.tmpl"]
1920
files <- fmap ("docs/" </>) <$> getDirectoryFiles "docs" ["*.md"]
2021
need files
21-
cmd "pandoc" files ["-o"] out ["--template", "resources/page.tmpl"]
22+
cmd ("pandoc" :: String) files ["-o" :: String] out (["--template", "resources/page.tmpl"] :: [String])
2223

2324
"output//*.wiki" %> \out -> do
2425
let src = dropDirectory1 $ out -<.> "md"
25-
cmd "pandoc" src "-o" out ["-t", "mediawiki"]
26+
cmd ("pandoc" :: String) src ("-o" :: String) out (["-t", "mediawiki"] :: [String])

package.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: scheme
2+
version: 0.1
3+
synopsis: Write You a Scheme
4+
license-file: LICENSE
5+
author: "Adam Wespiser"
6+
maintainer: "adamwespiser@gmail.com"
7+
8+
default-extensions:
9+
- OverloadedStrings
10+
11+
dependencies:
12+
- base >= 4.8 && <5.0
13+
- bytestring
14+
- containers
15+
- directory
16+
- haskeline
17+
- mtl
18+
- optparse-applicative
19+
- parsec
20+
- text
21+
- transformers
22+
- HTTP
23+
- tasty
24+
- tasty-golden
25+
- hspec
26+
27+
ghc-options:
28+
- -Werror
29+
- -fno-warn-unused-do-bind
30+
- -fno-warn-unused-binds
31+
- -fno-warn-type-defaults
32+
- -fno-warn-type-defaults
33+
- -fno-warn-name-shadowing
34+
- -fwarn-duplicate-exports
35+
- -fwarn-dodgy-exports
36+
- -fwarn-dodgy-imports
37+
- -fwarn-incomplete-patterns
38+
- -fwarn-incomplete-record-updates
39+
- -fwarn-missing-fields
40+
- -fwarn-missing-methods
41+
- -fwarn-orphans
42+
- -fwarn-overlapping-patterns
43+
- -fwarn-unused-imports
44+
- -fwarn-tabs
45+
- -fwarn-unrecognised-pragmas
46+
47+
library:
48+
source-dirs: src/
49+
50+
executables:
51+
scheme:
52+
main: Main.hs
53+
source-dirs: exec
54+
dependencies:
55+
- base >= 4.8 && < 5
56+
- scheme
57+
docs:
58+
main: Build.hs
59+
dependencies:
60+
- base >= 4.8 && < 5.0
61+
- shake
62+
- pandoc
63+
64+
tests:
65+
test:
66+
main: Main.hs
67+
source-dirs: test-hs/Spec/
68+
dependencies:
69+
- scheme
70+
- hspec
71+
ghc-options:
72+
- -threaded
73+
- -rtsopts
74+
- -with-rtsopts=-N
75+
test-golden:
76+
main: Main.hs
77+
source-dirs: test-hs/Golden
78+
dependencies:
79+
- scheme
80+
- tasty
81+
- tasty-golden
82+
- bytestring
83+
ghc-options:
84+
- -threaded
85+
- -rtsopts
86+
- -with-rtsopts=-N
87+

scheme.cabal

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/Eval.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Parser
2020
import LispVal
2121

2222
import Data.Map as Map
23-
import Data.Monoid
2423
import qualified Data.Text as T
2524
import qualified Data.Text.IO as TIO
2625
import System.Directory

src/Prim.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import LispVal
66

77
import Data.Text as T
88
import Data.Text.IO as TIO
9-
import Data.Monoid
109
import System.Directory
1110
import System.IO
1211
import Network.HTTP

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-7.12
1+
resolver: lts-16.17
22
packages:
33
- '.'
44
extra-deps: []

test-hs/Golden.hs renamed to test-hs/Golden/Main.hs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
module Main (main) where
33

44
import LispVal
5-
import Parser
65
import Eval
76

87
import qualified Data.Text as T
98

109
import Test.Tasty
1110
import Test.Tasty.Golden
1211
import qualified Data.ByteString.Lazy.Char8 as C
12+
import Data.Functor ((<&>))
1313

1414
main :: IO ()
1515
main = defaultMain tests
@@ -30,7 +30,7 @@ tests = testGroup "Golden Tests"
3030
, tastyGoldenRun "greater than" "test/test_gt.scm" "test/ans/test_gt.txt"
3131
, tastyGoldenRun "lexical scope 1" "test/test_scope1.scm" "test/ans/test_scope1.txt"
3232
, tastyGoldenRun "lexical scope 2" "test/test_scope2.scm" "test/ans/test_scope2.txt"
33-
, tastyGoldenRun "issue #23" "test/test_scope3.scm" "test/ans/test_scope3.txt"
33+
, tastyGoldenFail "issue #23" "test/test_scope3.scm" "test/ans/test_scope3.txt"
3434
, tastyGoldenRun "issue #25" "test/test_scope4.scm" "test/ans/test_scope4.txt"
3535
, tastyGoldenRun "Recursion 1" "test/test_fix.scm" "test/ans/test_fix.txt"
3636
, tastyGoldenRun "Recursion 2" "test/test_fix2.scm" "test/ans/test_fix2.txt"
@@ -40,13 +40,18 @@ tests = testGroup "Golden Tests"
4040
]
4141

4242
tastyGoldenRun :: TestName -> T.Text -> FilePath -> TestTree
43-
tastyGoldenRun testName testFile correct = goldenVsString testName correct (evalTextTest (Just "lib/stdlib.scm") (testFile) >>= (return . C.pack . show))
44-
45-
evalTextTest :: Maybe T.Text -> T.Text -> IO LispVal --REPL
46-
evalTextTest (Just stdlib) file= do
47-
stdlib <- getFileContents $ T.unpack stdlib
48-
f <- getFileContents $ T.unpack file
49-
runASTinEnv basicEnv $ textToEvalForm stdlib f
50-
evalTextTest Nothing file = do
43+
tastyGoldenRun testName testFile correct =
44+
goldenVsString testName correct $
45+
evalTextTest "lib/stdlib.scm" testFile <&> C.pack . show
46+
47+
tastyGoldenFail :: TestName -> T.Text -> FilePath -> TestTree
48+
tastyGoldenFail testName testFile correct =
49+
goldenVsString testName correct $
50+
(safeExec $ evalTextTest "lib/stdlib.scm" testFile) <&>
51+
either C.pack (C.pack . show)
52+
53+
evalTextTest :: T.Text -> T.Text -> IO LispVal --REPL
54+
evalTextTest stdlib file= do
55+
stdlib' <- getFileContents $ T.unpack stdlib
5156
f <- getFileContents $ T.unpack file
52-
runASTinEnv basicEnv $ fileToEvalForm (T.unpack file) f
57+
runASTinEnv basicEnv $ textToEvalForm stdlib' f
File renamed without changes.

test/ans/test_let.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
101

0 commit comments

Comments
 (0)