disable doctests conditionally
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
gyehoek = final.haskell-nix.project' {
|
gyehoek = final.haskell-nix.project' {
|
||||||
src = ./.;
|
src = ./.;
|
||||||
compiler-nix-name = "ghc912";
|
compiler-nix-name = "ghc912";
|
||||||
|
configureArgs = "-f-doctest";
|
||||||
modules = [({ pkgs, lib, ...}: {
|
modules = [({ pkgs, lib, ...}: {
|
||||||
packages.gyehoek.components.tests.test.preCheck =
|
packages.gyehoek.components.tests.test.preCheck =
|
||||||
let
|
let
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
ret > ExitSuccess
|
ret > ExitSuccess
|
||||||
out > 720
|
out > 2432902008176640000
|
||||||
|
|||||||
@@ -2,5 +2,4 @@
|
|||||||
(if (zero? n)
|
(if (zero? n)
|
||||||
1
|
1
|
||||||
(* n (fac (- n 1)))))))
|
(* n (fac (- n 1)))))))
|
||||||
;; 20 is the greatest `n` for which n! ≤ maxBount @Int
|
|
||||||
(fac 20))
|
(fac 20))
|
||||||
|
|||||||
+16
-8
@@ -13,6 +13,11 @@ build-type: Simple
|
|||||||
-- extra-doc-files: CHANGELOG.md
|
-- extra-doc-files: CHANGELOG.md
|
||||||
-- extra-source-files:
|
-- extra-source-files:
|
||||||
|
|
||||||
|
flag doctest
|
||||||
|
description: enable the doctest suite
|
||||||
|
default: True
|
||||||
|
manual: True
|
||||||
|
|
||||||
common ghcstuffs-dev
|
common ghcstuffs-dev
|
||||||
ghc-options:
|
ghc-options:
|
||||||
-Wno-unused-matches -Wno-missing-signatures -Wno-typed-holes
|
-Wno-unused-matches -Wno-missing-signatures -Wno-typed-holes
|
||||||
@@ -156,11 +161,14 @@ test-suite test
|
|||||||
default-language: GHC2024
|
default-language: GHC2024
|
||||||
|
|
||||||
-- https://github.com/martijnbastiaan/doctest-parallel/pull/66
|
-- https://github.com/martijnbastiaan/doctest-parallel/pull/66
|
||||||
-- test-suite doctest
|
test-suite doctest
|
||||||
-- import: ghcstuffs, ghcstuffs-dev
|
import: ghcstuffs, ghcstuffs-dev
|
||||||
-- type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
-- hs-source-dirs: test
|
hs-source-dirs: test
|
||||||
-- main-is: doctest.hs
|
build-depends: base
|
||||||
-- build-depends:
|
default-extensions: CPP
|
||||||
-- , base
|
main-is: doctest.hs
|
||||||
-- , doctest-parallel >=0.1
|
if flag(doctest)
|
||||||
|
build-depends: doctest-parallel >=0.1
|
||||||
|
else
|
||||||
|
cpp-options: "-DGYEHOEK_NO_DOCTEST"
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ instance S.DataIso Block where
|
|||||||
|
|
||||||
instance S.DatumIso Tail where
|
instance S.DatumIso Tail where
|
||||||
datumIso = S.match
|
datumIso = S.match
|
||||||
$ S.With (S.headTagged1' "tail-call!" S.datumIso S.datumIso >>>)
|
$ S.With (S.headTagged1' "tail-call" S.datumIso S.datumIso >>>)
|
||||||
$ S.With (if_ >>>)
|
$ S.With (if_ >>>)
|
||||||
$ S.End
|
$ S.End
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -16,23 +16,23 @@ test_root = testGroup "stack machine"
|
|||||||
evalsTo [ObjImm (ImmInt 3)] [stkP|
|
evalsTo [ObjImm (ImmInt 3)] [stkP|
|
||||||
(define ($main)
|
(define ($main)
|
||||||
(pop-cont! %ktail)
|
(pop-cont! %ktail)
|
||||||
(tail-call! %ktail 3))
|
(tail-call %ktail 3))
|
||||||
|]
|
|]
|
||||||
, testCase "return constant" do
|
, testCase "return constant" do
|
||||||
evalsTo [ObjImm (ImmInt 123)] [stkP|
|
evalsTo [ObjImm (ImmInt 123)] [stkP|
|
||||||
(define ($main)
|
(define ($main)
|
||||||
(tail-call! $silly))
|
(tail-call $silly))
|
||||||
(define ($silly)
|
(define ($silly)
|
||||||
(pop-cont! %ktail)
|
(pop-cont! %ktail)
|
||||||
(tail-call! %ktail 123))
|
(tail-call %ktail 123))
|
||||||
|]
|
|]
|
||||||
, testCase "identity function" do
|
, testCase "identity function" do
|
||||||
evalsTo [ObjImm (ImmInt 45)] [stkP|
|
evalsTo [ObjImm (ImmInt 45)] [stkP|
|
||||||
(define ($main)
|
(define ($main)
|
||||||
(tail-call! $id 45))
|
(tail-call $id 45))
|
||||||
(define ($id %x)
|
(define ($id %x)
|
||||||
(pop-cont! %ktail)
|
(pop-cont! %ktail)
|
||||||
(tail-call! %ktail %x))
|
(tail-call %ktail %x))
|
||||||
|]
|
|]
|
||||||
-- , testCase "square" do
|
-- , testCase "square" do
|
||||||
-- evalsTo [ObjImm (ImmInt 16)] [stkP|
|
-- evalsTo [ObjImm (ImmInt 16)] [stkP|
|
||||||
@@ -41,11 +41,11 @@ test_root = testGroup "stack machine"
|
|||||||
, testCase "square" do
|
, testCase "square" do
|
||||||
evalsTo [ObjImm (ImmInt 16)] [stkP|
|
evalsTo [ObjImm (ImmInt 16)] [stkP|
|
||||||
(define ($main)
|
(define ($main)
|
||||||
(tail-call! $square 4))
|
(tail-call $square 4))
|
||||||
(define ($square %x)
|
(define ($square %x)
|
||||||
(prim %x2 (* %x %x))
|
(prim %x2 (* %x %x))
|
||||||
(pop-cont! %ktail)
|
(pop-cont! %ktail)
|
||||||
(tail-call! %ktail %x2))
|
(tail-call %ktail %x2))
|
||||||
|]
|
|]
|
||||||
, testCase "factorial" do
|
, testCase "factorial" do
|
||||||
let hsfac (n :: Int) = foldr (*) (1) [1..n]
|
let hsfac (n :: Int) = foldr (*) (1) [1..n]
|
||||||
@@ -54,18 +54,18 @@ test_root = testGroup "stack machine"
|
|||||||
(prim %x0 (zero? %n))
|
(prim %x0 (zero? %n))
|
||||||
(if %x0
|
(if %x0
|
||||||
(then (pop-cont! %ktail)
|
(then (pop-cont! %ktail)
|
||||||
(tail-call! %ktail 1))
|
(tail-call %ktail 1))
|
||||||
(else (push! %n)
|
(else (push! %n)
|
||||||
(prim %x1 (- %n 1))
|
(prim %x1 (- %n 1))
|
||||||
(push-cont! $fac-k0)
|
(push-cont! $fac-k0)
|
||||||
(tail-call! $fac %x1))))
|
(tail-call $fac %x1))))
|
||||||
(define ($fac-k0 %x2)
|
(define ($fac-k0 %x2)
|
||||||
(pop! %n)
|
(pop! %n)
|
||||||
(prim %x3 (* %x2 %n))
|
(prim %x3 (* %x2 %n))
|
||||||
(pop-cont! %ktail)
|
(pop-cont! %ktail)
|
||||||
(tail-call! %ktail %x3))
|
(tail-call %ktail %x3))
|
||||||
(define ($main)
|
(define ($main)
|
||||||
(tail-call! $fac #{n}))
|
(tail-call $fac #{n}))
|
||||||
|]
|
|]
|
||||||
evalsTo [ObjImm (ImmInt 1)] $ fac 0
|
evalsTo [ObjImm (ImmInt 1)] $ fac 0
|
||||||
evalsTo [ObjImm (ImmInt 1)] $ fac 1
|
evalsTo [ObjImm (ImmInt 1)] $ fac 1
|
||||||
@@ -73,32 +73,3 @@ test_root = testGroup "stack machine"
|
|||||||
-- 20 is the greatest `n` for which n! ≤ maxBount @Int
|
-- 20 is the greatest `n` for which n! ≤ maxBount @Int
|
||||||
evalsTo [ObjImm (ImmInt 2432902008176640000)] $ fac 20
|
evalsTo [ObjImm (ImmInt 2432902008176640000)] $ fac 20
|
||||||
]
|
]
|
||||||
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- prims = testGroup "prims"
|
|
||||||
-- [ arith
|
|
||||||
-- , testCase "zero?" do
|
|
||||||
-- trivialPrimTest [ObjImm (ImmBool True)] $
|
|
||||||
-- PrimZeroP $ ValImm $ ImmInt 0
|
|
||||||
-- trivialPrimTest [ObjImm (ImmBool False)] $
|
|
||||||
-- PrimZeroP $ ValImm $ ImmInt 12
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- trivialPrimTest rs p =
|
|
||||||
-- evalsTo rs
|
|
||||||
-- [ MkRoutine "main" []
|
|
||||||
-- [ PopCont "ktail"
|
|
||||||
-- , Prim "x1" p
|
|
||||||
-- , Call (ValReg "ktail") [ValReg "x1"]
|
|
||||||
-- ]
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- arith = testGroup "arith"
|
|
||||||
-- [ testCase "multipy" do
|
|
||||||
-- trivialPrimTest [ObjImm (ImmInt 12)]
|
|
||||||
-- (PrimMul (ValImm $ ImmInt 3) (ValImm $ ImmInt 4))
|
|
||||||
-- , testCase "subtract" do
|
|
||||||
-- trivialPrimTest [ObjImm (ImmInt 14)]
|
|
||||||
-- (PrimSub (ValImm $ ImmInt 20) (ValImm $ ImmInt 6))
|
|
||||||
-- ]
|
|
||||||
|
|||||||
+9
-3
@@ -1,10 +1,16 @@
|
|||||||
{-# LANGUAGE DoAndIfThenElse #-}
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
|
#ifndef GYEHOEK_NO_DOCTEST
|
||||||
import Test.DocTest (mainFromCabal)
|
import Test.DocTest (mainFromCabal)
|
||||||
import System.Environment (getArgs, lookupEnv)
|
#endif
|
||||||
|
import System.Environment (getArgs)
|
||||||
import System.IO (stderr, hPutStrLn)
|
import System.IO (stderr, hPutStrLn)
|
||||||
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = mainFromCabal "gyehoek" =<< getArgs
|
main =
|
||||||
|
#ifndef GYEHOEK_NO_DOCTEST
|
||||||
|
mainFromCabal "gyehoek" =<< getArgs
|
||||||
|
#else
|
||||||
|
hPutStrLn stderr "skipping doctests due to broken nix environment."
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user