packages feed

replace-megaparsec 1.4.5.0 → 1.5.0.0

raw patch · 10 files changed

+153/−259 lines, 10 filesdep +hspecdep −Cabaldep ~basedep ~bytestringdep ~megaparsecPVP ok

version bump matches the API change (PVP)

Dependencies added: hspec

Dependencies removed: Cabal

Dependency ranges changed: base, bytestring, megaparsec, parser-combinators, text

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,17 @@ # Revision history for replace-megaparsec +## 1.5.0.0 -- 2023-05-30++Upgrade to GHC v9.4.4, text v2.0.1++Text does not work with GHC v9.4.3++Test+* exitcode-stdio-1.0 instead of detailed-0.9+* HSpec instead of Cabal Distribution.TestSuite++Added megaparsec version bounds #36+ ## 1.4.5.0 -- 2022-04-14  Minor documentation changes.
README.md view
@@ -3,7 +3,6 @@ [![Hackage](https://img.shields.io/hackage/v/replace-megaparsec.svg?style=flat)](https://hackage.haskell.org/package/replace-megaparsec) [![Stackage Nightly](http://stackage.org/package/replace-megaparsec/badge/nightly)](http://stackage.org/nightly/package/replace-megaparsec) [![Stackage LTS](http://stackage.org/package/replace-megaparsec/badge/lts)](http://stackage.org/lts/package/replace-megaparsec)-[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jamesdbrock/replace-megaparsec/master?urlpath=lab/tree/work/ReplaceMegaparsecUsage.ipynb)  * [Usage Examples](#usage-examples) * [In the Shell](#in-the-shell)
replace-megaparsec.cabal view
@@ -1,10 +1,10 @@+cabal-version:       3.0 name:                replace-megaparsec-version:             1.4.5.0-cabal-version:       1.18-synopsis:            Find, replace, and split string patterns with Megaparsec parsers (instead of regex)+version:             1.5.0.0+synopsis:            Find, replace, split string patterns with Megaparsec parsers (instead of regex) homepage:            https://github.com/jamesdbrock/replace-megaparsec bug-reports:         https://github.com/jamesdbrock/replace-megaparsec/issues-license:             BSD2+license:             BSD-2-Clause license-file:        LICENSE author:              James Brock <jamesbrock@gmail.com> maintainer:          James Brock <jamesbrock@gmail.com>@@ -24,49 +24,25 @@  library   hs-source-dirs:      src-  build-depends:       base >= 4.0 && < 5.0-                     , megaparsec-                     , bytestring-                     , text-                     , parser-combinators >= 1.2.0+  build-depends:       base >=4.0 && <5.0+                     , megaparsec >=7.0.0 && <10.0.0+                     , bytestring >=0.2 && <1.0+                     , text >=0.2 && <3.0+                     , parser-combinators >=1.2.0 && < 2.0.0   default-language:    Haskell2010   exposed-modules:     Replace.Megaparsec                      , Replace.Megaparsec.Internal.ByteString                      , Replace.Megaparsec.Internal.Text-  ghc-options:         -O2 -Wall -test-suite test-string-  type:                detailed-0.9-  test-module:         TestString-  hs-source-dirs:      tests-  default-language:    Haskell2010-  build-depends:       base >= 4.0 && < 5.0-                     , replace-megaparsec-                     , megaparsec-                     , Cabal-  ghc-options:         -Wall--test-suite test-text-  type:                detailed-0.9-  test-module:         TestText+test-suite test+  type:                exitcode-stdio-1.0+  main-is:             Test.hs   hs-source-dirs:      tests+  other-modules:       TestString, TestByteString, TestText   default-language:    Haskell2010-  build-depends:       base >= 4.0 && < 5.0+  build-depends:       base                      , replace-megaparsec                      , megaparsec-                     , Cabal+                     , hspec >=2.0.0 && <3.0.0                      , text-  ghc-options:         -Wall--test-suite test-bytestring-  type:                detailed-0.9-  test-module:         TestByteString-  hs-source-dirs:      tests-  default-language:    Haskell2010-  build-depends:       base >= 4.0 && < 5.0-                     , replace-megaparsec-                     , megaparsec-                     , Cabal                      , bytestring-  ghc-options:         -Wall-
src/Replace/Megaparsec.hs view
@@ -88,7 +88,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE CPP #-}-{-# LANGUAGE TupleSections #-}+{-# LANGUAGE TypeOperators #-}  module Replace.Megaparsec   (
src/Replace/Megaparsec/Internal/ByteString.hs view
@@ -14,6 +14,7 @@  {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}  module Replace.Megaparsec.Internal.ByteString   (
src/Replace/Megaparsec/Internal/Text.hs view
@@ -14,6 +14,7 @@  {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}  module Replace.Megaparsec.Internal.Text   (
+ tests/Test.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE BlockArguments #-}++module Main ( main ) where++import Test.Hspec+import TestString+import TestByteString+import TestText++main :: IO ()+main = hspec do+  TestString.tests+  TestByteString.tests+  TestText.tests
tests/TestByteString.hs view
@@ -2,10 +2,10 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE BlockArguments #-}  module TestByteString ( tests ) where -import Distribution.TestSuite as TestSuite import Replace.Megaparsec import Text.Megaparsec import Text.Megaparsec.Byte@@ -14,103 +14,71 @@ import qualified Data.ByteString as B import Data.ByteString.Internal (c2w) import GHC.Word+import Test.Hspec (describe, shouldBe, it, SpecWith)  type Parser = Parsec Void B.ByteString  findAllCap' :: MonadParsec e s m => m a -> m [Either (Tokens s) (Tokens s, a)] findAllCap' sep = sepCap (match sep) -tests :: IO [Test]-tests = return-    [ Test $ runParserTest "findAll upperChar"+tests :: SpecWith ()+tests = describe "input ByteString" do+    runParserTest "findAll upperChar"         (findAllCap' (upperChar :: Parser Word8))         ("aBcD" :: B.ByteString)         [Left "a", Right ("B", c2w 'B'), Left "c", Right ("D", c2w 'D')]     -- check that sepCap can progress even when parser consumes nothing     -- and succeeds.-    , Test $ runParserTest "zero-consumption parser"+    runParserTest "zero-consumption parser"         (sepCap (many (upperChar :: Parser Word8)))         ("aBcD" :: B.ByteString)         [Left "a", Right [c2w 'B'], Left "c", Right [c2w 'D']]-    , Test $ runParserTest "scinum"+    runParserTest "scinum"         (sepCap scinum)-        ("1E3")-        ([Right (1,3)])-    , Test $ runParserTest "getOffset"+        "1E3"+        [Right (1,3)]+    runParserTest "getOffset"         (sepCap offsetA)-        ("xxAxx")-        ([Left "xx", Right 2, Left "xx"])-    , Test $ runParserTest "monad fail"+        "xxAxx"+        [Left "xx", Right 2, Left "xx"]+    runParserTest "monad fail"         (sepCap (fail "" :: Parser ()))-        ("xxx")-        ([Left "xxx"])+        "xxx"+        [Left "xxx"] #if MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)-    , Test $ runParserTest "read fail"+    runParserTest "read fail"         (sepCap (return (read "a" :: Int) :: Parser Int))-        ("a")-        ([Left "a"])+        "a"+        [Left "a"] #endif-    , Test $ runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" []-    , Test $ streamEditTest "x to o"+    runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" []+    streamEditTest "x to o"         (string "x" :: Parser B.ByteString) (const "o")         "x x x" "o o o"-    , Test $ streamEditTest "x to o inner"+    streamEditTest "x to o inner"         (string "x" :: Parser B.ByteString) (const "o")         " x x x " " o o o "-    , Test $ streamEditTest "ordering"+    streamEditTest "ordering"         (string "456" :: Parser B.ByteString) (const "ABC")         "123456789" "123ABC789"-    , Test $ streamEditTest "empty input" (match (fail "" :: Parser ())) (fst) "" ""-    , Test $ breakCapTest "basic" (upperChar :: Parser Word8) "aAa" (Just ("a", c2w 'A', "a"))-    , Test $ breakCapTest "first" (upperChar :: Parser Word8) "Aa" (Just ("", c2w 'A', "a"))-    , Test $ breakCapTest "last" (upperChar :: Parser Word8) "aA" (Just ("a", c2w 'A', ""))-    , Test $ breakCapTest "fail" (upperChar :: Parser Word8) "aaa" Nothing-    , Test $ breakCapTest "match" (match (upperChar :: Parser Word8)) "aAa" (Just ("a", ("A",c2w 'A'), "a"))-    , Test $ breakCapTest "zero-width" (lookAhead (upperChar :: Parser Word8)) "aAa" (Just ("a", c2w 'A', "Aa"))-    , Test $ breakCapTest "empty input" (upperChar :: Parser Word8) "" Nothing-    , Test $ breakCapTest "empty input zero-width" (return () :: Parser ()) "" (Just ("", (), ""))-    ]+    streamEditTest "empty input" (match (fail "" :: Parser ())) fst "" ""+    breakCapTest "basic" (upperChar :: Parser Word8) "aAa" (Just ("a", c2w 'A', "a"))+    breakCapTest "first" (upperChar :: Parser Word8) "Aa" (Just ("", c2w 'A', "a"))+    breakCapTest "last" (upperChar :: Parser Word8) "aA" (Just ("a", c2w 'A', ""))+    breakCapTest "fail" (upperChar :: Parser Word8) "aaa" Nothing+    breakCapTest "match" (match (upperChar :: Parser Word8)) "aAa" (Just ("a", ("A",c2w 'A'), "a"))+    breakCapTest "zero-width" (lookAhead (upperChar :: Parser Word8)) "aAa" (Just ("a", c2w 'A', "Aa"))+    breakCapTest "empty input" (upperChar :: Parser Word8) "" Nothing+    breakCapTest "empty input zero-width" (return () :: Parser ()) "" (Just ("", (), ""))   where-    runParserTest nam p input expected = TestInstance-            { run = do-                case runParser p "" input of-                    Left e -> return (Finished $ Fail $ show e)-                    Right output ->-                        if (output == expected)-                            then return (Finished Pass)-                            else return (Finished $ Fail-                                        $ "got " <> show output <> " expected " <> show expected)-            , name = nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    runParserTest nam p input expected = it nam $ shouldBe+        (runParser p "" input) (Right expected) -    streamEditTest nam sep editor input expected = TestInstance-            { run = do-                let output = streamEdit sep editor input-                if (output == expected)-                    then return (Finished Pass)-                    else return (Finished $ TestSuite.Fail-                                $ "got " <> show output <> " expected " <> show expected)-            , name = "streamEdit " ++ nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    streamEditTest nam sep editor input expected = it nam $ shouldBe+        (streamEdit sep editor input) expected -    breakCapTest nam sep input expected = TestInstance-            { run = do-                let output = breakCap sep input-                if (output == expected)-                    then return (Finished Pass)-                    else return (Finished $ TestSuite.Fail-                                $ "got " <> show output <> " expected " <> show expected)-            , name = "breakCap " ++ nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    breakCapTest nam sep input expected = it nam $ shouldBe+        (breakCap sep input) expected      scinum :: Parser (Double, Integer)     scinum = do
tests/TestString.hs view
@@ -1,16 +1,16 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE BlockArguments #-}  module TestString ( tests ) where -import Distribution.TestSuite-import Distribution.TestSuite as TestSuite import Replace.Megaparsec import Text.Megaparsec import Text.Megaparsec.Char import Data.Void import Data.Bifunctor (second)+import Test.Hspec (describe, shouldBe, it, SpecWith)  type Parser = Parsec Void String @@ -20,101 +20,68 @@ findAll' :: MonadParsec e s f => f b -> f [Either (Tokens s) (Tokens s)] findAll' sep = (fmap.fmap) (second fst) $ sepCap (match sep) -tests :: IO [Test]-tests = return-    [ Test $ runParserTest "findAll upperChar"+tests :: SpecWith ()+tests = describe "input String" do+    runParserTest "findAll upperChar"         (findAllCap' (upperChar :: Parser Char))         ("aBcD" :: String)         [Left "a", Right ("B", 'B'), Left "c", Right ("D", 'D')]     -- check that sepCap can progress even when parser consumes nothing     -- and succeeds.-    , Test $ runParserTest "zero-consumption parser"+    runParserTest "zero-consumption parser"         (sepCap (many (upperChar :: Parser Char)))         ("aBcD" :: String)         [Left "a", Right "B", Left "c", Right "D"]-    , Test $ runParserTest "scinum"+    runParserTest "scinum"         (sepCap scinum)-        ("1E3")-        ([Right (1,3)])-    , Test $ runParserTest "getOffset"+        "1E3"+        [Right (1,3)]+    runParserTest "getOffset"         (sepCap offsetA)-        ("xxAxx")-        ([Left "xx", Right 2, Left "xx"])-    , Test $ runParserTest "monad fail"+        "xxAxx"+        [Left "xx", Right 2, Left "xx"]+    runParserTest "monad fail"         (sepCap (fail "" :: Parser ()))-        ("xxx")-        ([Left "xxx"])+        "xxx"+        [Left "xxx"] #if MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)-    , Test $ runParserTest "read fail"+    runParserTest "read fail"         (sepCap (return (read "a" :: Int) :: Parser Int))         ("a")         ([Left "a"]) #endif-    , Test $ runParserTest "findAll astral"-        (findAll' ((takeWhileP Nothing (=='𝅘𝅥𝅯') :: Parser String)))-        ("𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥")+    runParserTest "findAll astral"+        (findAll' (takeWhileP Nothing (=='𝅘𝅥𝅯') :: Parser String))+        "𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥"         [Left "𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥", Right "𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯", Left "𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥"]-    , Test $ runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" []-    , Test $ streamEditTest "x to o"+    runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" []+    streamEditTest "x to o"         (string "x" :: Parser String) (const "o")         "x x x" "o o o"-    , Test $ streamEditTest "x to o inner"+    streamEditTest "x to o inner"         (string "x" :: Parser String) (const "o")         " x x x " " o o o "-    , Test $ streamEditTest "ordering"+    streamEditTest "ordering"         (string "456" :: Parser String) (const "ABC")         "123456789" "123ABC789"-    , Test $ streamEditTest "empty input" (match (fail "" :: Parser ())) (fst) "" ""-    , Test $ breakCapTest "basic" (upperChar :: Parser Char) "aAa" (Just ("a", 'A', "a"))-    , Test $ breakCapTest "first" (upperChar :: Parser Char) "Aa" (Just ("", 'A', "a"))-    , Test $ breakCapTest "last" (upperChar :: Parser Char) "aA" (Just ("a", 'A', ""))-    , Test $ breakCapTest "fail" (upperChar :: Parser Char) "aaa" Nothing-    , Test $ breakCapTest "match" (match (upperChar :: Parser Char)) "aAa" (Just ("a", ("A",'A'), "a"))-    , Test $ breakCapTest "zero-width" (lookAhead (upperChar :: Parser Char)) "aAa" (Just ("a", 'A', "Aa"))-    , Test $ breakCapTest "empty input" (upperChar :: Parser Char) "" Nothing-    , Test $ breakCapTest "empty input zero-width" (return () :: Parser ()) "" (Just ("", (), ""))-    ]+    streamEditTest "empty input" (match (fail "" :: Parser ())) fst "" ""+    breakCapTest "basic" (upperChar :: Parser Char) "aAa" (Just ("a", 'A', "a"))+    breakCapTest "first" (upperChar :: Parser Char) "Aa" (Just ("", 'A', "a"))+    breakCapTest "last" (upperChar :: Parser Char) "aA" (Just ("a", 'A', ""))+    breakCapTest "fail" (upperChar :: Parser Char) "aaa" Nothing+    breakCapTest "match" (match (upperChar :: Parser Char)) "aAa" (Just ("a", ("A",'A'), "a"))+    breakCapTest "zero-width" (lookAhead (upperChar :: Parser Char)) "aAa" (Just ("a", 'A', "Aa"))+    breakCapTest "empty input" (upperChar :: Parser Char) "" Nothing+    breakCapTest "empty input zero-width" (return () :: Parser ()) "" (Just ("", (), ""))   where-    runParserTest nam p input expected = TestInstance-            { run = do-                case runParser p "" input of-                    Left e -> return (Finished $ Fail $ show e)-                    Right output ->-                        if (output == expected)-                            then return (Finished Pass)-                            else return (Finished $ Fail-                                        $ "got " <> show output <> " expected " <> show expected)-            , name = nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    runParserTest nam p input expected = it nam $ shouldBe+        (runParser p "" input) (Right expected) -    streamEditTest nam sep editor input expected = TestInstance-            { run = do-                let output = streamEdit sep editor input-                if (output == expected)-                    then return (Finished Pass)-                    else return (Finished $ TestSuite.Fail-                                $ "got " <> show output <> " expected " <> show expected)-            , name = "streamEdit " ++ nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    streamEditTest nam sep editor input expected = it nam $ shouldBe+        (streamEdit sep editor input) expected -    breakCapTest nam sep input expected = TestInstance-            { run = do-                let output = breakCap sep input-                if (output == expected)-                    then return (Finished Pass)-                    else return (Finished $ TestSuite.Fail-                                $ "got " <> show output <> " expected " <> show expected)-            , name = "breakCap " ++ nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    breakCapTest nam sep input expected = it nam $ shouldBe+        (breakCap sep input) expected      scinum :: Parser (Double, Integer)     scinum = do@@ -122,7 +89,6 @@         _ <- chunk "E"         e <- some digitChar         return (read m, read e)-      offsetA :: Parser Int     offsetA = getOffset <* chunk "A"
tests/TestText.hs view
@@ -2,17 +2,17 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE BlockArguments #-}  module TestText ( tests ) where -import Distribution.TestSuite-import Distribution.TestSuite as TestSuite import Replace.Megaparsec import Text.Megaparsec import Text.Megaparsec.Char import Data.Void import qualified Data.Text as T import Data.Bifunctor (second)+import Test.Hspec (describe, shouldBe, it, SpecWith)  type Parser = Parsec Void T.Text @@ -22,118 +22,75 @@ findAll' :: MonadParsec e s f => f b -> f [Either (Tokens s) (Tokens s)] findAll' sep = (fmap.fmap) (second fst) $ sepCap (match sep) -tests :: IO [Test]-tests = return-    [ Test $ runParserTest "findAll upperChar"+tests :: SpecWith ()+tests = describe "input Text" do+    runParserTest "findAll upperChar"         (findAllCap' (upperChar :: Parser Char))         ("aBcD" :: T.Text)         [Left "a", Right ("B", 'B'), Left "c", Right ("D", 'D')]     -- check that sepCap can progress even when parser consumes nothing     -- and succeeds.-    , Test $ runParserTest "zero-consumption parser"+    runParserTest "zero-consumption parser"         (sepCap (many (upperChar :: Parser Char)))         ("aBcD" :: T.Text)         [Left "a", Right "B", Left "c", Right "D"]-    , Test $ runParserTest "scinum"+    runParserTest "scinum"         (sepCap scinum)         ("1E3")         ([Right (1,3)])-    , Test $ runParserTest "getOffset"+    runParserTest "getOffset"         (sepCap offsetA)         ("xxAxx")         ([Left "xx", Right 2, Left "xx"])-    , Test $ runParserTest "monad fail"+    runParserTest "monad fail"         (sepCap (fail "" :: Parser ()))         ("xxx")         ([Left "xxx"]) #if MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)-    , Test $ runParserTest "read fail"+    runParserTest "read fail"         (sepCap (return (read "a" :: Int) :: Parser Int))         ("a")         ([Left "a"]) #endif-    , Test $ runParserTest "findAll astral"-        (findAll' ((takeWhileP Nothing (=='𝅘𝅥𝅯') :: Parser T.Text)))+    runParserTest "findAll astral"+        (findAll' (takeWhileP Nothing (=='𝅘𝅥𝅯') :: Parser T.Text))         ("𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥" :: T.Text)         [Left "𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥", Right "𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯", Left "𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥"]-    , Test $ runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" []-    , Test $ streamEditTest "x to o"+    runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" []+    streamEditTest "x to o"         (string "x" :: Parser T.Text) (const "o")         "x x x" "o o o"-    , Test $ streamEditTest "x to o inner"+    streamEditTest "x to o inner"         (string "x" :: Parser T.Text) (const "o")         " x x x " " o o o "-    , Test $ streamEditTest "ordering"+    streamEditTest "ordering"         (string "456" :: Parser T.Text) (const "ABC")         "123456789" "123ABC789"-    , Test $ streamEditTest "empty input" (match (fail "" :: Parser ())) (fst) "" ""-    , Test $ breakCapTest "basic" (upperChar :: Parser Char) "aAa" (Just ("a", 'A', "a"))-    , Test $ breakCapTest "first" (upperChar :: Parser Char) "Aa" (Just ("", 'A', "a"))-    , Test $ breakCapTest "last" (upperChar :: Parser Char) "aA" (Just ("a", 'A', ""))-    , Test $ breakCapTest "fail" (upperChar :: Parser Char) "aaa" Nothing-    , Test $ breakCapTest "match" (match (upperChar :: Parser Char)) "aAa" (Just ("a", ("A",'A'), "a"))-    , Test $ breakCapTest "zero-width" (lookAhead (upperChar :: Parser Char)) "aAa" (Just ("a", 'A', "Aa"))-    , Test $ breakCapTest "empty input" (upperChar :: Parser Char) "" Nothing-    , Test $ breakCapTest "empty input zero-width" (return () :: Parser ()) "" (Just ("", (), ""))+    streamEditTest "empty input" (match (fail "" :: Parser ())) fst "" ""+    breakCapTest "basic" (upperChar :: Parser Char) "aAa" (Just ("a", 'A', "a"))+    breakCapTest "first" (upperChar :: Parser Char) "Aa" (Just ("", 'A', "a"))+    breakCapTest "last" (upperChar :: Parser Char) "aA" (Just ("a", 'A', ""))+    breakCapTest "fail" (upperChar :: Parser Char) "aaa" Nothing+    breakCapTest "match" (match (upperChar :: Parser Char)) "aAa" (Just ("a", ("A",'A'), "a"))+    breakCapTest "zero-width" (lookAhead (upperChar :: Parser Char)) "aAa" (Just ("a", 'A', "Aa"))+    breakCapTest "empty input" (upperChar :: Parser Char) "" Nothing+    breakCapTest "empty input zero-width" (return () :: Parser ()) "" (Just ("", (), ""))     -- I was unable to write a failing test for     -- https://github.com/jamesdbrock/replace-megaparsec/issues/33     -- but adding this "sep backtrack" test anyway-    , Test $ splitCapTest "sep backtrack" (match $ between (string "{{") (string "}}") (T.pack <$> many (alphaNumChar <|> spaceChar) :: Parser T.Text)) "{{foo.}}" [Left "{{foo.}}"]-    ]+    splitCapTest "sep backtrack" (match $ between (string "{{") (string "}}") (T.pack <$> many (alphaNumChar <|> spaceChar) :: Parser T.Text)) "{{foo.}}" [Left "{{foo.}}"]   where-    runParserTest nam p input expected = TestInstance-            { run = do-                case runParser p "" input of-                    Left e -> return (Finished $ Fail $ show e)-                    Right output ->-                        if (output == expected)-                            then return (Finished Pass)-                            else return (Finished $ Fail-                                        $ "got " <> show output <> " expected " <> show expected)-            , name = nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    runParserTest nam p input expected = it nam $ shouldBe+        (runParser p "" input) (Right expected) -    streamEditTest nam sep editor input expected = TestInstance-            { run = do-                let output = streamEdit sep editor input-                if (output == expected)-                    then return (Finished Pass)-                    else return (Finished $ TestSuite.Fail-                                $ "got " <> show output <> " expected " <> show expected)-            , name = "streamEdit " ++ nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    streamEditTest nam sep editor input expected = it nam $ shouldBe+        (streamEdit sep editor input) expected -    breakCapTest nam sep input expected = TestInstance-            { run = do-                let output = breakCap sep input-                if (output == expected)-                    then return (Finished Pass)-                    else return (Finished $ TestSuite.Fail-                                $ "got " <> show output <> " expected " <> show expected)-            , name = "breakCap " ++ nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    breakCapTest nam sep input expected = it nam $ shouldBe+        (breakCap sep input) expected -    splitCapTest nam sep input expected = TestInstance-            { run = do-                let output = splitCap sep input-                if (output == expected)-                    then return (Finished Pass)-                    else return (Finished $ TestSuite.Fail-                                $ "got " <> show output <> " expected " <> show expected)-            , name = "splitCap " ++ nam-            , tags = []-            , options = []-            , setOption = \_ _ -> Left "no options supported"-            }+    splitCapTest nam sep input expected = it nam $ shouldBe+        (splitCap sep input) expected      scinum :: Parser (Double, Integer)     scinum = do