-
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 pull request #498 from objectionary/483-test-command
483 test command
- Loading branch information
Showing
14 changed files
with
158 additions
and
77 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
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
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.
500b251
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to retrieve PDD puzzles from the code base and submit them to github. If you think that it's a bug on our side, please submit it to yegor256/0pdd:
Please, copy and paste this stack trace to GitHub: