From b296cddce619a692a08f5571055772ee731c8cd2 Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Fri, 29 Dec 2023 01:31:34 +0300 Subject: [PATCH] Change the test Yaml format to an array of tests Co-authored-by: Danila Danko --- eo-phi-normalizer/test/Language/EO/PhiSpec.hs | 4 ++-- eo-phi-normalizer/test/Test/EO/Phi.hs | 2 +- eo-phi-normalizer/test/eo/phi/normal-1.yaml | 7 ------- eo-phi-normalizer/test/eo/phi/normal-2.yaml | 7 ------- eo-phi-normalizer/test/eo/phi/rule-1.yaml | 15 +++++++++++++++ eo-phi-normalizer/test/eo/phi/rule-5.yaml | 7 +++++++ eo-phi-normalizer/test/eo/phi/test.yaml | 7 ------- 7 files changed, 25 insertions(+), 24 deletions(-) delete mode 100644 eo-phi-normalizer/test/eo/phi/normal-1.yaml delete mode 100644 eo-phi-normalizer/test/eo/phi/normal-2.yaml create mode 100644 eo-phi-normalizer/test/eo/phi/rule-1.yaml create mode 100644 eo-phi-normalizer/test/eo/phi/rule-5.yaml delete mode 100644 eo-phi-normalizer/test/eo/phi/test.yaml diff --git a/eo-phi-normalizer/test/Language/EO/PhiSpec.hs b/eo-phi-normalizer/test/Language/EO/PhiSpec.hs index 195d02d05..a4b22d891 100644 --- a/eo-phi-normalizer/test/Language/EO/PhiSpec.hs +++ b/eo-phi-normalizer/test/Language/EO/PhiSpec.hs @@ -14,10 +14,10 @@ spec :: Spec spec = do tests <- runIO (allPhiTests "test/eo/phi/") describe "Normalizer" $ do - forM_ tests $ \PhiTest{..} -> do + forM_ tests $ mapM_ $ \PhiTest{..} -> do it name $ do Phi.printTree (Phi.normalize input) `shouldBe` Phi.printTree normalized describe "Prettify" $ do - forM_ tests $ \PhiTest{..} -> do + forM_ tests $ mapM_ $ \PhiTest{..} -> do it name $ do Phi.printTree input `shouldBe` dropWhileEnd isSpace prettified diff --git a/eo-phi-normalizer/test/Test/EO/Phi.hs b/eo-phi-normalizer/test/Test/EO/Phi.hs index b4f9f16ff..0f98d1fb2 100644 --- a/eo-phi-normalizer/test/Test/EO/Phi.hs +++ b/eo-phi-normalizer/test/Test/EO/Phi.hs @@ -24,7 +24,7 @@ data PhiTest = PhiTest } deriving (Generic, FromJSON) -allPhiTests :: FilePath -> IO [PhiTest] +allPhiTests :: FilePath -> IO [[PhiTest]] allPhiTests dir = do paths <- listDirectory dir forM (sort paths) $ \path -> diff --git a/eo-phi-normalizer/test/eo/phi/normal-1.yaml b/eo-phi-normalizer/test/eo/phi/normal-1.yaml deleted file mode 100644 index 053ba0630..000000000 --- a/eo-phi-normalizer/test/eo/phi/normal-1.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: 'Program in normal form (1)' -input: | - {} -normalized: | - { ν ↦ { Δ ⤍ 0 } } -prettified: | - { ν ↦ { Δ ⤍ 0 } } diff --git a/eo-phi-normalizer/test/eo/phi/normal-2.yaml b/eo-phi-normalizer/test/eo/phi/normal-2.yaml deleted file mode 100644 index 5b885cbe2..000000000 --- a/eo-phi-normalizer/test/eo/phi/normal-2.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: 'Program in normal form (2)' -input: | - { φ ↦ { φ ↦ { φ ↦ { } } } } -normalized: | - { ν ↦ { Δ ⤍ 3 }, φ ↦ { ν ↦ { Δ ⤍ 2 }, φ ↦ { ν ↦ { Δ ⤍ 1 }, φ ↦ { ν ↦ { Δ ⤍ 0 } } } } } -prettified: | - { ν ↦ { Δ ⤍ 3 }, φ ↦ { ν ↦ { Δ ⤍ 2 }, φ ↦ { ν ↦ { Δ ⤍ 1 }, φ ↦ { ν ↦ { Δ ⤍ 0 } } } } } diff --git a/eo-phi-normalizer/test/eo/phi/rule-1.yaml b/eo-phi-normalizer/test/eo/phi/rule-1.yaml new file mode 100644 index 000000000..1652f59e5 --- /dev/null +++ b/eo-phi-normalizer/test/eo/phi/rule-1.yaml @@ -0,0 +1,15 @@ +- name: 'Program in normal form (1)' + input: | + {} + normalized: | + { ν ↦ { Δ ⤍ 00- } } + prettified: | + { } + +- name: 'Program in normal form (2)' + input: | + { φ ↦ { φ ↦ { φ ↦ { } } } } + normalized: | + { ν ↦ { Δ ⤍ 03- }, φ ↦ { ν ↦ { Δ ⤍ 02- }, φ ↦ { ν ↦ { Δ ⤍ 01- }, φ ↦ { ν ↦ { Δ ⤍ 00- } } } } } + prettified: | + { φ ↦ { φ ↦ { φ ↦ { } } } } diff --git a/eo-phi-normalizer/test/eo/phi/rule-5.yaml b/eo-phi-normalizer/test/eo/phi/rule-5.yaml new file mode 100644 index 000000000..5ae468e8b --- /dev/null +++ b/eo-phi-normalizer/test/eo/phi/rule-5.yaml @@ -0,0 +1,7 @@ +- name: 'Simple static attribute reference' + input: | + { φ ↦ { } , a ↦ ξ.φ } + normalized: | + { ν ↦ { Δ ⤍ 01- }, φ ↦ { ν ↦ { Δ ⤍ 00- } }, a ↦ ξ.φ } + prettified: | + { φ ↦ { }, a ↦ ξ.φ } diff --git a/eo-phi-normalizer/test/eo/phi/test.yaml b/eo-phi-normalizer/test/eo/phi/test.yaml deleted file mode 100644 index 07ebcb315..000000000 --- a/eo-phi-normalizer/test/eo/phi/test.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: 'Simple static attribute reference' -input: | - { φ ↦ { } , a ↦ ξ.φ } -normalized: | - { ν ↦ { Δ ⤍ 1 }, φ ↦ { ν ↦ { Δ ⤍ 0 } }, a ↦ ξ.φ } -prettified: | - { ν ↦ { Δ ⤍ 1 }, φ ↦ { ν ↦ { Δ ⤍ 0 } }, a ↦ ξ.φ }