-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into 479-mismatch-of-names-of-t…
…he-binary-and-package
- Loading branch information
Showing
17 changed files
with
210 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{-# LANGUAGE BlockArguments #-} | ||
{-# LANGUAGE OverloadedRecordDot #-} | ||
|
||
module Language.EO.Test.YamlSpec where | ||
|
||
import Control.Monad (forM_) | ||
import Language.EO.Phi.Dataize.Context (defaultContext) | ||
import Language.EO.Phi.Rules.Common (applyOneRule) | ||
import Language.EO.Phi.Rules.Yaml (Rule (..), RuleSet (..), RuleTest (..), RuleTestOption (..), convertRuleNamed) | ||
import Language.EO.Test.Yaml | ||
import Test.Hspec | ||
|
||
spec :: [FilePath] -> Spec | ||
spec testPaths = describe "User-defined rules unit tests" do | ||
forM_ testPaths $ \path -> do | ||
ruleset <- runIO $ fileTests path | ||
describe ruleset.title do | ||
forM_ ruleset.rules $ \rule -> do | ||
describe rule.name do | ||
forM_ rule.tests $ \ruleTest -> do | ||
it ruleTest.name $ | ||
let rule' = convertRuleNamed rule | ||
resultOneStep = applyOneRule (defaultContext [rule'] ruleTest.input) ruleTest.input | ||
normalizationResult = maybe resultOneStep (\lst -> if TakeOne True `elem` lst then take 1 resultOneStep else resultOneStep) ruleTest.options | ||
expected = ruleTest.output | ||
in map snd normalizationResult `shouldBe` expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,13 @@ | ||
{-# LANGUAGE BlockArguments #-} | ||
{-# LANGUAGE OverloadedRecordDot #-} | ||
|
||
module Language.EO.YamlSpec where | ||
|
||
import Control.Monad (forM_) | ||
import Language.EO.Phi.Dataize.Context (defaultContext) | ||
import Language.EO.Phi.Rules.Common (applyOneRule) | ||
import Language.EO.Phi.Rules.Yaml (Rule (..), RuleSet (..), RuleTest (..), RuleTestOption (..), convertRuleNamed) | ||
import Test.EO.Yaml | ||
import Test.Hspec | ||
import Language.EO.Test.YamlSpec qualified as Test | ||
import Test.Hspec (Spec) | ||
|
||
spec :: Spec | ||
spec = describe "User-defined rules unit tests" do | ||
forM_ testPaths $ \path -> do | ||
ruleset <- runIO $ fileTests path | ||
describe ruleset.title do | ||
forM_ ruleset.rules $ \rule -> do | ||
describe rule.name do | ||
forM_ rule.tests $ \ruleTest -> do | ||
it ruleTest.name $ | ||
let rule' = convertRuleNamed rule | ||
resultOneStep = applyOneRule (defaultContext [rule'] ruleTest.input) ruleTest.input | ||
normalizationResult = maybe resultOneStep (\lst -> if TakeOne True `elem` lst then take 1 resultOneStep else resultOneStep) ruleTest.options | ||
expected = ruleTest.output | ||
in map snd normalizationResult `shouldBe` expected | ||
where | ||
testPaths = | ||
spec = | ||
Test.spec | ||
[ "test/eo/phi/rules/yegor.yaml" | ||
, "test/eo/phi/rules/streams.yaml" | ||
] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.