From f8fb64a53edcc7ea98ceddb5a3a35cd6916c27a7 Mon Sep 17 00:00:00 2001 From: krangelov Date: Thu, 18 Nov 2021 13:55:57 +0100 Subject: [PATCH] added test case for showPGF --- src/runtime/haskell/tests/basic.hs | 4 +++ src/runtime/haskell/tests/basic.pmcfg | 36 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/runtime/haskell/tests/basic.pmcfg diff --git a/src/runtime/haskell/tests/basic.hs b/src/runtime/haskell/tests/basic.hs index b6eca2d5a..257aa54b6 100644 --- a/src/runtime/haskell/tests/basic.hs +++ b/src/runtime/haskell/tests/basic.hs @@ -6,6 +6,7 @@ import PGF2 main = do g <- newStdGen + let limit = 10 ^ 100 ns = take 5000 (randomRs (-limit,limit) g) @@ -79,6 +80,7 @@ main = do gr1 <- readPGF "tests/basic.pgf" gr2 <- bootNGF "tests/basic.pgf" "tests/basic.ngf" gr3 <- readNGF "tests/basic.ngf" + pmcfg <- readFile "tests/basic.pmcfg" rp1 <- testLoadFailure (readPGF "non-existing.pgf") rp2 <- testLoadFailure (readPGF "tests/basic.gf") @@ -103,6 +105,8 @@ main = do ,TestCase (assertBool "wrong file format (GF)" rn2) ,TestCase (assertBool "wrong file format (PGF)" rn3) + + ,TestCase (assertEqual "show pgf" (init pmcfg) (showPGF gr1)) ] ++ grammarTests gr1 ++ grammarTests gr2 diff --git a/src/runtime/haskell/tests/basic.pmcfg b/src/runtime/haskell/tests/basic.pmcfg new file mode 100644 index 000000000..ab7574652 --- /dev/null +++ b/src/runtime/haskell/tests/basic.pmcfg @@ -0,0 +1,36 @@ +abstract basic { + cat Float ; -- 0.693147 + cat Int ; -- 0.693147 + cat N ; -- 0.693147 + cat P N ; -- 0.693147 + cat S ; -- 0.693147 + cat String ; -- 0.693147 + data c : N -> S ; -- -0 + fun ind : P z -> ((x : N) -> P x -> P (s x)) -> (x : N) -> P x ; -- -0 + data s : N -> N ; -- 0.693147 + data z : N ; -- 0.693147 +} +concrete basic_cnc { + lincat N = [ + "s" + ] + lincat P = [ + ] + lincat S = [ + "" + ] + lin c : N(j) -> S(0) = [ + <0,0> + ] + lin ind : P(0) * P(0) * N(j) -> P(0) = [ + ] + lin s : N(0) -> N(0) = [ + <0,0> "+" "1" + ] + lin s : N(1) -> N(0) = [ + "1" + ] + lin z : N(1) = [ + "0" + ] +}