sexp-grammar 2.3.0 → 2.3.1
raw patch · 5 files changed
+30/−13 lines, 5 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- README.md +1/−1
- sexp-grammar.cabal +1/−1
- src/Language/Sexp/Located.hs +0/−1
- src/Language/Sexp/Types.hs +1/−1
- test/Main.hs +27/−9
README.md view
@@ -1,4 +1,4 @@-[](https://travis-ci.org/esmolanka/sexp-grammar)+[](https://github.com/esmolanka/sexp-grammar/actions/workflows/build.yml) sexp-grammar ============
sexp-grammar.cabal view
@@ -1,5 +1,5 @@ name: sexp-grammar-version: 2.3.0+version: 2.3.1 license: BSD3 license-file: LICENSE author: Yevhen Smolanka, Sergey Vinokurov
src/Language/Sexp/Located.hs view
@@ -40,7 +40,6 @@ ) where import Data.ByteString.Lazy.Char8 (ByteString, unpack)-import Data.Fix (Fix (..)) import Data.Functor.Compose import Data.Scientific (Scientific) import Data.Text (Text)
src/Language/Sexp/Types.hs view
@@ -30,7 +30,7 @@ import Data.Functor.Foldable (cata) import Data.Scientific (Scientific) import Data.Text (Text)-import Data.Text.Prettyprint.Doc (Pretty (..), colon, (<>))+import Data.Text.Prettyprint.Doc (Pretty (..), colon) import GHC.Generics ----------------------------------------------------------------------
test/Main.hs view
@@ -60,7 +60,7 @@ ]) , AtomSymbol . TS.pack <$> listOf (arbitrary `suchThat` (\c -> isAlphaNum c || c `elem` ("#',`\\:@!$%&*/<=>?~_^.|+-" :: [Char])))- `suchThat` (\s -> not $ all isDigit (drop 1 s) || null s || all (`elem` ("#',`" :: [Char])) (take 1 s))+ `suchThat` isValidSymbol , pure (AtomSymbol ":foo") , pure (AtomSymbol "1e2") , pure (AtomSymbol "-1e2")@@ -71,7 +71,18 @@ , pure (AtomSymbol "символ") , pure (AtomSymbol "@baz") ]+ where+ isValidSymbol = \case+ [] -> False+ p : _ | p `elem` ("#',`" :: String) -> False+ '+' : str -> not (isANumber str)+ str -> not (isANumber str) + isANumber s =+ case reads s of+ [(_ :: Double, [])] -> True+ _ -> False+ instance Arbitrary Prefix where arbitrary = elements [ Quote@@ -225,11 +236,8 @@ allTests :: TestTree allTests = testGroup "All tests"- [ lexerTests- , QC.testProperty "Format/decode invertibility"- (\a -> case Sexp.decode (Sexp.format a) of- Left _ -> trace "Cannot parse" False- Right b -> if toSimple a == toSimple b then True else trace ("Parsed " ++ show b) False)+ [ lexerParserTests+ , QC.testProperty "Format/decode invertibility" prop_decodeFormattedEq , grammarTests ] @@ -251,8 +259,8 @@ Left err -> "Error message: " ++ show (pretty err) Right v -> "Output: " ++ show v -lexerTests :: TestTree-lexerTests = testGroup "Sexp lexer/parser tests"+lexerParserTests :: TestTree+lexerParserTests = testGroup "Sexp lexer/parser tests" [ testCase "123 is an integer number" $ parseSexp' "123" `sexpEq` Right (Number 123)@@ -262,7 +270,7 @@ , testCase "-123 is an integer number" $ parseSexp' "-123" `sexpEq` Right (Number (- 123))- , testCase "+123.45 is a floating number" $+ , testCase "+123.45 is a floating point number" $ parseSexp' "+123.45" `sexpEq` Right (Number (read "123.45" :: Scientific)) , testCase "0_1 is a symbol" $@@ -344,6 +352,16 @@ parseSexp' ":foo" `sexpEq` Right (Symbol ":foo") ]+++prop_decodeFormattedEq :: Sexp -> Bool+prop_decodeFormattedEq a =+ case Sexp.decode (Sexp.format a) of+ Left _ -> trace "Cannot parse" False+ Right b ->+ let a' = toSimple a+ b' = toSimple b+ in if a' == b' then True else trace ("Mismatch: " ++ show a' ++ " /= " ++ show b') False grammarTests :: TestTree