expectedParserSelected :: CommandParser -> TestTree
expectedParserSelected expectedCommandParser =
    testProperty testName $
        forAll (commandString expectedCommandParser) $ \s ->
            let expectedName = expectedCommandName (Ev $ T.pack s)
                actualName   = actualCommandName (Ev $ T.pack s)
            in counterexample (errorMessage s actualName)
                              (expectedName == actualName)
  where
    unE = T.unpack . _unEv
    expectedCommandName = commandNameFor [cpParser expectedCommandParser . unE]
    actualCommandName   = commandNameFor defExCommandParsers
    commandNameFor parsers s =
        cmdShow <$> evStringToExCommand parsers s
    errorMessage s actualName =
        "Parsed " <> show s <> " to " <> show actualName <> " command"
    testName =
       cpDescription expectedCommandParser <> " selected for expected input"



-- | Tests for the Ex command parsers in the Vim Keymap.
--
-- Tests that the parsers parse the strings they are expected to and that
-- the expected parser is selected for string.
--
-- The actions of the ex commands are not tested here.
expectedParserSelected :: CommandParser -> TestTree
expectedParserSelected expectedCommandParser =
    testProperty testName $
        forAll (commandString expectedCommandParser) $ \s ->
            let expectedName = expectedCommandName (Ev $ T.pack s)
                actualName   = actualCommandName (Ev $ T.pack s)
            in counterexample (errorMessage s actualName)
                              (expectedName == actualName)
  where
    unE = T.unpack . _unEv
    expectedCommandName = commandNameFor [cpParser expectedCommandParser . unE]
    actualCommandName   = commandNameFor defExCommandParsers
    commandNameFor parsers s =
        cmdShow <$> evStringToExCommand parsers s
    errorMessage s actualName =
        "Parsed " <> show s <> " to " <> show actualName <> " command"
    testName =
       cpDescription expectedCommandParser <> " selected for expected input"



-- | Tests for the Ex command parsers in the Vim Keymap.
--
-- Tests that the parsers parse the strings they are expected to and that
-- the expected parser is selected for string.
--
-- The actions of the ex commands are not tested here.
expectedParserSelected expectedCommandParser =
    testProperty testName $
        forAll (commandString expectedCommandParser) $ \s ->
            let expectedName = expectedCommandName (Ev $ T.pack s)
                actualName   = actualCommandName (Ev $ T.pack s)
            in counterexample (errorMessage s actualName)
                              (expectedName == actualName)
  where
    unE = T.unpack . _unEv
    expectedCommandName = commandNameFor [cpParser expectedCommandParser . unE]
    actualCommandName   = commandNameFor defExCommandParsers
    commandNameFor parsers s =
        cmdShow <$> evStringToExCommand parsers s
    errorMessage s actualName =
        "Parsed " <> show s <> " to " <> show actualName <> " command"
    testName =
       cpDescription expectedCommandParser <> " selected for expected input"



-- | Tests for the Ex command parsers in the Vim Keymap.
--
-- Tests that the parsers parse the strings they are expected to and that
-- the expected parser is selected for string.
--
-- The actions of the ex commands are not tested here.