From 9059b7468b15bb51c1e01095613bafa17c9b349c Mon Sep 17 00:00:00 2001 From: Joshua Grosso Date: Tue, 27 Dec 2022 14:13:58 -0700 Subject: [PATCH] Add more regression tests for #79 --- axel.cabal | 4 ++-- package.yaml | 1 + test/Axel/Test/ParseSpec.hs | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/axel.cabal b/axel.cabal index e83844e..ab2b82b 100644 --- a/axel.cabal +++ b/axel.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 16a2f236cab672265c3e9c61bc8aa1cae5c514a879b3e109a31e037b80289124 +-- hash: 530edf888246232c289b1b3a3b7c1ec3fce359443c322e94e14706e1c5b3fb57 name: axel version: 0.0.13 @@ -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 diff --git a/package.yaml b/package.yaml index 66a5456..8df92be 100644 --- a/package.yaml +++ b/package.yaml @@ -129,5 +129,6 @@ tests: - -threaded - -rtsopts - -with-rtsopts=-N + - -Wno-name-shadowing dependencies: - axel diff --git a/test/Axel/Test/ParseSpec.hs b/test/Axel/Test/ParseSpec.hs index 9a8037a..0a1016b 100644 --- a/test/Axel/Test/ParseSpec.hs +++ b/test/Axel/Test/ParseSpec.hs @@ -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 @@ -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 @@ -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