Commit e38e705e authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢
Browse files

Merge branch 'mini-tests-cleanup'

parents e00fce23 8c07590f
......@@ -11,10 +11,13 @@
# \ |
# -----------'
# b
#
# where q1 is the initial state and q3 the only final state.
{f,n}xX^{a,b}
@init q1
q1: (n, {a: q2, b: q3})
q2: (n, {a: q1, b: q3})
q3: (f, {a: q1, b: q2})
{f, n}xX^{a, b}
@init s0_q1_q2
s0_q1_q2: (n, {a: s0_q1_q2, b: s1_q3})
s1_q3: (f, {a: s0_q1_q2, b: s0_q1_q2})
\ No newline at end of file
s1_q3: (f, {a: s0_q1_q2, b: s0_q1_q2})
......@@ -13,4 +13,4 @@ s09_d5: {(s10_d6, s02_b2_b3_bot)}
s10_d6: {(s11_d7, s02_b2_b3_bot)}
s11_d7: {(s12_d8, s02_b2_b3_bot)}
s12_d8: {(s13_d9, s02_b2_b3_bot)}
s13_d9: {(s05_d10, s02_b2_b3_bot)}
\ No newline at end of file
s13_d9: {(s05_d10, s02_b2_b3_bot)}
# A deterministic finite automaton:
#
# b
# -----------.
# / |
# .>q1 <------- |
# / | a \ v
# b| |a q3
# \ v b / ^
# `-q2 <------- |
# \ |
# -----------'
# b
{f,n}xX^{a,b}
@init q1
q1: (n, {a: q2, b: q3})
q2: (n, {a: q1, b: q3})
q3: (f, {a: q1, b: q2})
{f, n}xX^{a, b}
@init s0_q1_q2
s0_q1_q2: (n, {a: s0_q1_q2, b: s1_q3})
s1_q3: (f, {a: s0_q1_q2, b: s0_q1_q2})
\ No newline at end of file
......@@ -2,4 +2,4 @@ R^X
@init s1_zero
s1_zero: {}
\ No newline at end of file
s1_zero: {}
......@@ -12,4 +12,4 @@ s09_d5: {(s10_d6, s02_b2_b3_bot)}
s10_d6: {(s11_d7, s02_b2_b3_bot)}
s11_d7: {(s12_d8, s02_b2_b3_bot)}
s12_d8: {(s13_d9, s02_b2_b3_bot)}
s13_d9: {(s05_d10, s02_b2_b3_bot)}
\ No newline at end of file
s13_d9: {(s05_d10, s02_b2_b3_bot)}
{circled, normal} x Ƥ(ƤX)
a1: (normal, {{a1}})
\ No newline at end of file
a1: (normal, {{a1}})
R^(X)^{a, b}
s0_s1: {a: {s0_s1: 0.3}, b: {s0_s1: 0.8}}
\ No newline at end of file
s0_s1: {a: {s0_s1: 0.3}, b: {s0_s1: 0.8}}
......@@ -86,34 +86,35 @@ testFileMinimize mini =
process file `shouldReturn` minimized
where
process :: FilePath -> IO String
process file =
P.readFile P.defaultConfig file >>=
process file =
P.readFile P.defaultConfig file >>=
\case
Left err -> return err
Right (f, (symTab, enc)) -> do
part <- stToIO (refine (Proxy :: Proxy (Desorted SomeFunctor)) enc True)
let
let
(enc', symTab') = minimize f enc symTab part
return (LT.unpack . Build.toLazyText $ Build.fromText (printParseableFunctor f)
<> "\n\n"
<> printEncoding enc' symTab' (sortTable f))
return (LT.unpack . Build.toLazyText $ Build.fromText (printParseableFunctor f)
<> "\n\n"
<> printEncoding enc' symTab' (sortTable f)
<> "\n")
testFileMinimizeIdentity :: FilePath -> Spec
testFileMinimizeIdentity file =
specify ("minimizeIdentity " <> file) $ do
P.readFile P.defaultConfig file >>=
P.readFile P.defaultConfig file >>=
\case
Left err -> expectationFailure $ "initialParse: " <> err
Right (f, (symTab, enc)) -> do
part <- stToIO (refine (Proxy :: Proxy (Desorted SomeFunctor)) enc True)
let
let
(enc', symTab') = minimize f enc symTab part
coalgebra = Build.fromText (printParseableFunctor f)
coalgebra = Build.fromText (printParseableFunctor f)
<> "\n\n"
<> printEncoding enc' (anonymizeSymbols symTab') (sortTable f)
reparsed = P.parseCoalgebra P.defaultConfig "(minimized)" $ LT.toStrict (Build.toLazyText coalgebra)
case reparsed of
Left err -> expectationFailure $ "parseMinimized: " <> err
......@@ -122,7 +123,7 @@ testFileMinimizeIdentity file =
let
(enc''', symTab''') = minimize f' enc'' symTab'' part'
Build.fromText (printParseableFunctor f)
Build.fromText (printParseableFunctor f)
<> "\n\n"
<> (printEncoding enc''' (anonymizeSymbols symTab''') (sortTable f')) `shouldBe`
<> (printEncoding enc''' (anonymizeSymbols symTab''') (sortTable f')) `shouldBe`
coalgebra
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment