Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to resolver 20.11 #1158

Merged
merged 10 commits into from
May 2, 2023
Merged
2 changes: 1 addition & 1 deletion docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ in an *import statement* in the test suite, usually at the beginning:

```haskell
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import ModuleName (someFunc)

Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/guessing-game/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
2 changes: 1 addition & 1 deletion exercises/concept/lucians-luscious-lasagna/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
2 changes: 1 addition & 1 deletion exercises/concept/pacman-rules/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
2 changes: 1 addition & 1 deletion exercises/concept/temperature/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
2 changes: 1 addition & 1 deletion exercises/concept/valentines-day/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
2 changes: 1 addition & 1 deletion exercises/practice/accumulate/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/accumulate/test/Tests.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Data.Char (toUpper)
import Test.Hspec (Spec, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Accumulate (accumulate)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = do
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/acronym/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/acronym/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import Data.Foldable (for_)
import Data.String (fromString)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Acronym (abbreviate)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "abbreviate" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/all-your-base/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/all-your-base/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Base (Error(..), rebase)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "rebase" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/allergies/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/allergies/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Test.QuickCheck (Gen, forAll, forAllShrink, elements, sublistOf, suchThat)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)
import Data.List (delete)
import Data.Maybe (mapMaybe)

Expand All @@ -21,7 +21,7 @@ import Allergies
)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = do
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/alphametics/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/alphametics/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Data.Foldable (for_)
import Data.Function (on)
import Data.List (sort)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Alphametics (solve)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "solve" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/anagram/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/anagram/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import Data.Foldable (for_)
import GHC.Exts (fromList, toList)
import Test.Hspec (Spec, describe, it, shouldMatchList)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Anagram (anagramsFor)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "anagramsFor" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/armstrong-numbers/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/armstrong-numbers/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import ArmstrongNumbers (armstrong)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "armstrong" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/atbash-cipher/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/atbash-cipher/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)
import Data.String (fromString)

import Atbash (encode, decode)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = do
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/bank-account/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/bank-account/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Data.Foldable (for_)
import Data.Traversable (for)
import Data.Maybe (isNothing, catMaybes)
import Test.Hspec (Spec, it, shouldReturn)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import BankAccount
( closeAccount
Expand All @@ -14,7 +14,7 @@ import BankAccount
)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = do
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/beer-song/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/beer-song/test/Tests.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Control.Monad (unless)
import Test.Hspec (Spec, describe, expectationFailure, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Beer (song)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/binary-search-tree/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/binary-search-tree/test/Tests.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Test.Hspec (Spec, it, shouldBe, shouldNotBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import BST
( bstLeft
Expand All @@ -13,7 +13,7 @@ import BST
)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = do
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/binary-search/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/binary-search/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import Data.Array (Array, listArray)
import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import BinarySearch (find)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "find" $ for_ bases $ for_ cases . test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/binary/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/binary/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Binary (toDecimal)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "toDecimal" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/bob/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/bob/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)
import Data.String (fromString)

import Bob (responseFor)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "responseFor" $ for_ cases test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ scoreRoll scoreState rolls' = do

scoreRoll' :: Frame -> Int -> Int -> [Roll] -> ScoreState
scoreRoll' _ ri _ (r:_) | r < 0 || r > 10 = Left $ InvalidRoll ri r
scoreRoll' f@(Frame 10 (fr:_)) ri totalScore (r:_)
| throws f < 2 = Right (addRoll f r, succ ri, totalScore + fr + r)
| throws f == 2 && (fr == 10 || spare f) = addFillBall
| otherwise = Left $ InvalidRoll ri r -- no more rolls possible
scoreRoll' f@(Frame 10 (fr:_)) ri totalScore (r:_) = case rolls f of
[_] -> Right (addRoll f r, succ ri, totalScore + fr + r)
[firstRoll, secondRoll] | fr == 10 || spare f -> addFillBall firstRoll secondRoll
| otherwise -> noMoreRollsPossible
_ -> noMoreRollsPossible
where
addFillBall :: ScoreState
addFillBall
noMoreRollsPossible = Left $ InvalidRoll ri r
addFillBall :: Int -> Int -> ScoreState
addFillBall firstRoll secondRoll
| firstRoll == 10 && secondRoll /= 10 && secondRoll + r > 10 = Left $ InvalidRoll ri r
| otherwise = Right (addRoll f r, succ ri, totalScore + r)
where [firstRoll, secondRoll] = rolls f
scoreRoll' f@(Frame n _) ri totalScore rs@(r:_)
| complete f = Right (Frame (succ n) [r], succ ri, totalScore + fscore f rs)
| pins f + r <= 10 = Right (addRoll f r, succ ri, totalScore)
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/bowling/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/bowling/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Bowling (score, BowlingError(..))

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "roll, score" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/change/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/change/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import Data.Foldable (for_)
import Data.List (sort)
import Test.Hspec (Spec, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Change (findFewestCoins)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/clock/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/clock/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import Clock (addDelta, fromHourMin, toString)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = do
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/collatz-conjecture/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
4 changes: 2 additions & 2 deletions exercises/practice/collatz-conjecture/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import Data.Foldable (for_)
import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
import Test.Hspec.Runner (configFailFast, defaultConfig, hspecWith)

import CollatzConjecture (collatz)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs
main = hspecWith defaultConfig {configFailFast = True} specs

specs :: Spec
specs = describe "collatz" $ for_ cases test
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/complex-numbers/stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: lts-19.27
resolver: lts-20.18
Loading