Skip to content

Commit 2cf25c8

Browse files
committed
fix to exec unit and sample test
1 parent 1bdc64e commit 2cf25c8

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

egison.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Test-Suite test
8787
Hs-Source-Dirs: test
8888
Main-Is: Test.hs
8989
Build-Depends: egison, base >= 4.0 && < 5, transformers, mtl, Glob, HUnit, test-framework, test-framework-hunit, filepath
90-
Other-modules: Paths_egison
90+
Other-modules: Paths_egison, UnitTest
9191

9292
Benchmark benchmark
9393
Type: exitcode-stdio-1.0

test/Test.hs

+9-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ import Language.Egison.Core
1515
import Language.Egison.Primitives
1616
import Language.Egison
1717

18+
import UnitTest
19+
1820
main = do
19-
testCases <- glob "sample/pi.egi"
20-
defaultMain $ hUnitTestToTests $ test $ map runTestCase testCases
21+
unitTestCases <- glob "test/**/*.egi"
22+
defaultMain $ hUnitTestToTests $ test $ map runUnitTestCase unitTestCases
23+
sampleTestCases <- glob "sample/*.egi"
24+
defaultMain $ hUnitTestToTests $ test $ map runSampleTestCase sampleTestCases
2125

22-
runTestCase :: FilePath -> Test
23-
runTestCase file = TestLabel file . TestCase $ do
26+
runSampleTestCase :: FilePath -> Test
27+
runSampleTestCase file = TestLabel file . TestCase $ do
2428
env <- initialEnv
2529
let directory_path = takeDirectory file
2630
answers <- readFile (replaceDirectory file ("test/answer/" ++ directory_path))
@@ -34,7 +38,7 @@ runTestCase file = TestLabel file . TestCase $ do
3438
assertEgisonM answers m = fromEgisonM m >>= assertString . either show (f answers)
3539

3640
collectDefsAndTests (Define name expr) (bindings, tests) =
37-
(((stringToVar $ show name), expr) : bindings, tests)
41+
((stringToVar $ show name, expr) : bindings, tests)
3842
collectDefsAndTests (Test expr) (bindings, tests) =
3943
(bindings, expr : tests)
4044
collectDefsAndTests _ r = r

test/UnitTest.hs

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1-
module Main where
1+
module UnitTest ( runUnitTestCase ) where
22

33
import Control.Applicative
44
import Control.Monad
55
import Data.IORef
66

7-
import Test.Framework (defaultMain)
8-
import Test.Framework.Providers.HUnit (hUnitTestToTests)
97
import Test.HUnit
10-
import System.FilePath.Glob (glob)
118

129
import Language.Egison.Types
1310
import Language.Egison.Core
1411
import Language.Egison.Primitives
1512
import Language.Egison
1613

17-
main = do
18-
testCases <- glob "test/**/*.egi"
19-
defaultMain $ hUnitTestToTests $ test $ map runTestCase testCases
20-
21-
runTestCase :: FilePath -> Test
22-
runTestCase file = TestLabel file . TestCase $ do
14+
runUnitTestCase :: FilePath -> Test
15+
runUnitTestCase file = TestLabel file . TestCase $ do
2316
env <- initialEnv
2417
assertEgisonM $ do
2518
exprs <- loadFile file
@@ -31,7 +24,7 @@ runTestCase file = TestLabel file . TestCase $ do
3124
assertEgisonM m = fromEgisonM m >>= assertString . either show (const "")
3225

3326
collectDefsAndTests (Define name expr) (bindings, tests) =
34-
(((stringToVar $ show name), expr) : bindings, tests)
27+
((stringToVar $ show name, expr) : bindings, tests)
3528
collectDefsAndTests (Test expr) (bindings, tests) =
3629
(bindings, expr : tests)
3730
collectDefsAndTests _ r = r

0 commit comments

Comments
 (0)