Skip to content

Commit

Permalink
Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-adam committed Aug 18, 2024
1 parent 352a685 commit 9b74fa5
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 40 deletions.
7 changes: 7 additions & 0 deletions cabal.project
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
3 changes: 3 additions & 0 deletions docs/developers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 📅 Revision history for HelPS

## 0.1.0.1 -- 2024-08-18
* Upgrade

## 0.1.0.0 -- 2023-06-18
* First version. Released on an unsuspecting world.

Expand Down
2 changes: 1 addition & 1 deletion docs/reports/hlint.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<div id="content" valign="top" width="100%">
<p>
Report generated by <a href="http://community.haskell.org/~ndm/hlint/">HLint</a>
v3.1.6
v3.5
- a tool to suggest improvements to your Haskell code.
</p>

Expand Down
2 changes: 1 addition & 1 deletion docs/reports/stan.html

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion helps.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -106,6 +106,7 @@ library
HelVM.HelPS.HelPS

build-depends:
helio

ghc-options:

Expand All @@ -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
Expand Down
44 changes: 44 additions & 0 deletions hs/test/HelVM/Expectations.hs
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
66 changes: 66 additions & 0 deletions hs/test/HelVM/GoldenExpectations.hs
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
34 changes: 0 additions & 34 deletions hs/test/HelVM/HelPS/Assemblers/Expectations.hs

This file was deleted.

4 changes: 1 addition & 3 deletions hs/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ import Test.Hspec (hspec)
import Test.Hspec.Slow

main :: IO ()
main = do
config <- configure 1
hspec $ timeThese config Spec.spec
main = configure 1 >>= (hspec . flip timeThese Spec.spec)
6 changes: 6 additions & 0 deletions hs/test/SpecHook.hs
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

0 comments on commit 9b74fa5

Please sign in to comment.