cleanTests :: Spec
cleanTests = describe "unclean version strings" $ do
  let examples :: [(Text, Maybe Text)] = [
        ("1.2.3", Just "1.2.3"),
        (" 1.2.3 ", Just "1.2.3"),
        (" 1.2.3-4 ", Just "1.2.3-4"),
        (" 1.2.3-pre ", Just "1.2.3-pre"),
        ("  =v1.2.3   ", Just "1.2.3"),
        ("v1.2.3", Just "1.2.3"),
        (" v1.2.3 ", Just "1.2.3"),
        ("\t1.2.3", Just "1.2.3"),
        (">1.2.3", Nothing),
        ("~1.2.3", Nothing),
        ("<=1.2.3", Nothing)
        -- The example below is given in the tests but this doesn't
        -- seem like an error to me, so there.
        -- ("1.2.x", Nothing)
        ]
  forM_ examples $ \(string, result) -> case result of
    Just string' -> do
      it ("should parse " <> show string <> " same as " <> show string') $ do
        parseSemVer string `shouldSatisfy` isRight
        parseSemVer string `shouldBe` parseSemVer string'

    Nothing -> do
      it ("should not parse " <> show string) $ do
        parseSemVer string `shouldSatisfy` isLeft

-- | These test cases were adapted from
-- https://github.com/npm/node-semver/blob/master/test/index.js#L134
cleanTests :: Spec
cleanTests = describe "unclean version strings" $ do
  let examples :: [(Text, Maybe Text)] = [
        ("1.2.3", Just "1.2.3"),
        (" 1.2.3 ", Just "1.2.3"),
        (" 1.2.3-4 ", Just "1.2.3-4"),
        (" 1.2.3-pre ", Just "1.2.3-pre"),
        ("  =v1.2.3   ", Just "1.2.3"),
        ("v1.2.3", Just "1.2.3"),
        (" v1.2.3 ", Just "1.2.3"),
        ("\t1.2.3", Just "1.2.3"),
        (">1.2.3", Nothing),
        ("~1.2.3", Nothing),
        ("<=1.2.3", Nothing)
        -- The example below is given in the tests but this doesn't
        -- seem like an error to me, so there.
        -- ("1.2.x", Nothing)
        ]
  forM_ examples $ \(string, result) -> case result of
    Just string' -> do
      it ("should parse " <> show string <> " same as " <> show string') $ do
        parseSemVer string `shouldSatisfy` isRight
        parseSemVer string `shouldBe` parseSemVer string'

    Nothing -> do
      it ("should not parse " <> show string) $ do
        parseSemVer string `shouldSatisfy` isLeft

-- | These test cases were adapted from
-- https://github.com/npm/node-semver/blob/master/test/index.js#L134
cleanTests = describe "unclean version strings" $ do
  let examples :: [(Text, Maybe Text)] = [
        ("1.2.3", Just "1.2.3"),
        (" 1.2.3 ", Just "1.2.3"),
        (" 1.2.3-4 ", Just "1.2.3-4"),
        (" 1.2.3-pre ", Just "1.2.3-pre"),
        ("  =v1.2.3   ", Just "1.2.3"),
        ("v1.2.3", Just "1.2.3"),
        (" v1.2.3 ", Just "1.2.3"),
        ("\t1.2.3", Just "1.2.3"),
        (">1.2.3", Nothing),
        ("~1.2.3", Nothing),
        ("<=1.2.3", Nothing)
        -- The example below is given in the tests but this doesn't
        -- seem like an error to me, so there.
        -- ("1.2.x", Nothing)
        ]
  forM_ examples $ \(string, result) -> case result of
    Just string' -> do
      it ("should parse " <> show string <> " same as " <> show string') $ do
        parseSemVer string `shouldSatisfy` isRight
        parseSemVer string `shouldBe` parseSemVer string'

    Nothing -> do
      it ("should not parse " <> show string) $ do
        parseSemVer string `shouldSatisfy` isLeft

-- | These test cases were adapted from
-- https://github.com/npm/node-semver/blob/master/test/index.js#L134