-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
352a685
commit 9b74fa5
Showing
10 changed files
with
140 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
packages: *.cabal | ||
|
||
source-repository-package | ||
type: git | ||
location: https://github.com/helvm/helio.git | ||
branch: master | ||
tag: 0.1.2.3 |
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
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ license: Apache-2.0 | |
license-file: docs/license/LICENSE-APACHE | ||
author: Kamil Adam | ||
maintainer: [email protected] | ||
copyright: 2020-2023 WriteOnly Developers | ||
copyright: 2020-2024 WriteOnly Developers | ||
|
||
category: Language | ||
build-type: Simple | ||
|
@@ -106,6 +106,7 @@ library | |
HelVM.HelPS.HelPS | ||
|
||
build-depends: | ||
helio | ||
|
||
ghc-options: | ||
|
||
|
@@ -130,15 +131,24 @@ test-suite helps-test | |
main-is: Main.hs | ||
other-modules: | ||
Spec | ||
SpecHook | ||
|
||
HelVM.Expectations | ||
HelVM.GoldenExpectations | ||
|
||
build-depends: | ||
hspec | ||
, hspec-core | ||
, hspec-expectations-pretty-diff | ||
, hspec-golden | ||
, hspec-slow | ||
|
||
, helio | ||
, helps | ||
|
||
, filepath | ||
, type-operators | ||
|
||
build-tool-depends: hspec-discover:hspec-discover == 2.* | ||
ghc-options: | ||
-threaded | ||
|
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,44 @@ | ||
module HelVM.Expectations ( | ||
ioShouldSafe, | ||
ioShouldBe, | ||
shouldControlT, | ||
shouldSafeT, | ||
shouldSafeIO, | ||
shouldSafe, | ||
shouldBeDo, | ||
) where | ||
|
||
import HelVM.HelIO.Control.Control | ||
import HelVM.HelIO.Control.Safe | ||
|
||
import Test.Hspec.Expectations.Pretty | ||
|
||
infix 1 `ioShouldSafe` | ||
ioShouldSafe :: (Show a , Eq a) => IO (Safe a) -> IO a -> Expectation | ||
ioShouldSafe action expected = liftA2 shouldSafe action expected & join | ||
|
||
infix 1 `ioShouldBe` | ||
ioShouldBe :: (HasCallStack , Show a , Eq a) => IO a -> IO a -> Expectation | ||
ioShouldBe action expected = liftA2 shouldBe action expected & join | ||
|
||
---- | ||
|
||
infix 1 `shouldControlT` | ||
shouldControlT :: (Show a , Eq a) => ControlT IO a -> a -> Expectation | ||
shouldControlT action = shouldReturn (controlTToIOWithLogs action) | ||
|
||
infix 1 `shouldSafeT` | ||
shouldSafeT :: (Show a , Eq a) => SafeT IO a -> a -> Expectation | ||
shouldSafeT action = shouldReturn (safeTToIO action) | ||
|
||
infix 1 `shouldSafeIO` | ||
shouldSafeIO :: (Show a , Eq a) => IO (Safe a) -> a -> Expectation | ||
shouldSafeIO action = shouldReturn (safeIOToIO action) | ||
|
||
infix 1 `shouldSafe` | ||
shouldSafe :: (HasCallStack , Show a , Eq a) => Safe a -> a -> Expectation | ||
shouldSafe action expected = pure expected & shouldBe action | ||
|
||
infix 1 `shouldBeDo` | ||
shouldBeDo :: (HasCallStack , Show a , Eq a) => a -> IO a -> Expectation | ||
shouldBeDo action expected = expected >>= shouldBe action |
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,66 @@ | ||
module HelVM.GoldenExpectations ( | ||
(<->), | ||
|
||
goldenShouldControlT, | ||
goldenShouldSafeT, | ||
goldenShouldSafe, | ||
goldenShouldIO, | ||
goldenShouldBe, | ||
) where | ||
|
||
import HelVM.HelIO.Control.Control | ||
import HelVM.HelIO.Control.Safe | ||
|
||
import HelVM.HelIO.Extra | ||
|
||
import Control.Type.Operator | ||
import System.FilePath.Posix | ||
|
||
import Test.Hspec.Core.Spec | ||
import Test.Hspec.Golden | ||
|
||
infixl 1 <-> | ||
(<->) :: FilePath -> FilePath -> FilePath | ||
(<->) major minor = major <> "-" <> minor | ||
|
||
infix 1 `goldenShouldControlT` | ||
goldenShouldControlT :: ControlT IO Text -> FilePath -> GoldenExpectations Text | ||
goldenShouldControlT actualOutput = goldenShouldIO (controlTToIOWithLogs actualOutput) | ||
|
||
infix 1 `goldenShouldSafeT` | ||
goldenShouldSafeT :: SafeT IO Text -> FilePath -> GoldenExpectations Text | ||
goldenShouldSafeT actualOutput = goldenShouldIO (safeTToIO actualOutput) | ||
|
||
infix 1 `goldenShouldSafe` | ||
goldenShouldSafe :: Safe Text -> FilePath -> GoldenExpectations Text | ||
goldenShouldSafe actualOutputSafe = goldenShouldIO (safeToIO actualOutputSafe) | ||
|
||
infix 1 `goldenShouldIO` | ||
goldenShouldIO :: IO Text -> FilePath -> GoldenExpectations Text | ||
goldenShouldIO actualOutputIO fileName = GoldenExpectations $ flip goldenShouldBe fileName <$> actualOutputIO | ||
|
||
infix 1 `goldenShouldBe` | ||
goldenShouldBe :: Text -> FilePath -> Golden Text | ||
goldenShouldBe actualOutput fileName = | ||
Golden { | ||
output = actualOutput, | ||
encodePretty = show, | ||
writeToFile = writeFileText, | ||
readFromFile = readFileTextUtf8, | ||
goldenFile = ".output" </> "golden" </> fileName, | ||
actualFile = Just (".output" </> "actual" </> fileName), | ||
failFirstTime = False | ||
} | ||
|
||
---- | ||
|
||
newtype GoldenExpectations a = GoldenExpectations { unGoldenExpectations :: GoldenIO a } | ||
|
||
type GoldenIO a = IO $ Golden a | ||
|
||
---- | ||
|
||
instance Eq str => Example (GoldenExpectations str) where | ||
type Arg (GoldenExpectations str) = () | ||
evaluateExample wrapped params action callback = evaluateExample' =<< unGoldenExpectations wrapped where | ||
evaluateExample' unwrapped = evaluateExample unwrapped params action callback |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module SpecHook where | ||
|
||
import Test.Hspec | ||
|
||
hook :: Spec -> Spec | ||
hook = parallel |