Skip to content

Commit

Permalink
Add more regression tests for #79
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrosso committed Dec 27, 2022
1 parent 3cb21c0 commit 9059b74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions axel.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 16a2f236cab672265c3e9c61bc8aa1cae5c514a879b3e109a31e037b80289124
-- hash: 530edf888246232c289b1b3a3b7c1ec3fce359443c322e94e14706e1c5b3fb57

name: axel
version: 0.0.13
Expand Down Expand Up @@ -306,7 +306,7 @@ test-suite axel-test
TypeApplications
TypeFamilies
TypeOperators
ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-implicit-prelude -Wno-missed-specialisations -Wno-missing-deriving-strategies -Wno-missing-export-lists -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-missing-kind-signatures -Wno-missing-safe-haskell-mode -Wno-monomorphism-restriction -Wno-prepositive-qualified-module -Wno-safe -Wno-unsafe -Wno-unused-packages -optP-Wno-nonportable-include-path -O2 -fplugin=Effectful.Plugin -threaded -rtsopts -with-rtsopts=-N
ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-implicit-prelude -Wno-missed-specialisations -Wno-missing-deriving-strategies -Wno-missing-export-lists -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-missing-kind-signatures -Wno-missing-safe-haskell-mode -Wno-monomorphism-restriction -Wno-prepositive-qualified-module -Wno-safe -Wno-unsafe -Wno-unused-packages -optP-Wno-nonportable-include-path -O2 -fplugin=Effectful.Plugin -threaded -rtsopts -with-rtsopts=-N -Wno-name-shadowing
build-tool-depends:
hpack:hpack
, tasty-discover:tasty-discover
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,6 @@ tests:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -Wno-name-shadowing
dependencies:
- axel
16 changes: 16 additions & 0 deletions test/Axel/Test/ParseSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import Control.Monad
import qualified Effectful as Eff
import qualified Effectful.Error.Static as Eff

import Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range

import Test.Hspec

import TestUtils
Expand Down Expand Up @@ -61,6 +65,11 @@ spec_Parse = do
"can parse a string literal with a double quote at the end (regression: #79)" $ do
let result = LiteralString () "a \x1000 \""
parseSingle "\"a \x1000 \\\"\"" `shouldBe` result
it "can parse a string literal with escaped unprintables" $ do
let result = LiteralString () "\0"
parseSingle "\"\\0\"" `shouldBe` result
let result = LiteralString () "\NUL"
parseSingle "\"\\NUL\"" `shouldBe` result
it "can parse a quasiquoted expression" $ do
let result =
SExpression
Expand Down Expand Up @@ -160,3 +169,10 @@ spec_Parse = do
case Eff.runPureEff . Eff.runErrorNoCallStack $ parseSource Nothing input of
Left err -> failSpec $ renderError err
Right x -> void x `shouldBe` result

hprop_can_parse_string_literals :: Property
hprop_can_parse_string_literals =
property $ do
string <- forAll $ Gen.string (Range.linear 0 5) Gen.unicode
let result = parseSingle $ showText string
result === LiteralString () string

0 comments on commit 9059b74

Please sign in to comment.