Rename module ShellEscape → ShellParse

This commit is contained in:
Nikolay Yakimov
2015-12-20 08:26:49 +03:00
parent 057f6fba10
commit c3cf416097
4 changed files with 6 additions and 6 deletions

36
test/ShellParseSpec.hs Normal file
View File

@@ -0,0 +1,36 @@
module ShellParseSpec where
import GHCMod.Options.ShellParse
import Test.Hspec
spec :: Spec
spec =
describe "parseCmdLine" $ do
it "splits arguments" $
parseCmdLine "test command line" `shouldBe` ["test", "command", "line"]
it "honors double quotes" $
parseCmdLine "test command line \"with double quotes\""
`shouldBe` ["test", "command", "line", "with double quotes"]
it "escapes spaces" $ do
parseCmdLine "with\\ spaces"
`shouldBe` ["with spaces"]
parseCmdLine "\"with\\ spaces\""
`shouldBe` ["with spaces"]
it "escapes '\\'" $ do
parseCmdLine "\\\\"
`shouldBe` ["\\"]
parseCmdLine "\"\\\\\""
`shouldBe` ["\\"]
it "escapes double quotes" $ do
parseCmdLine "\\\""
`shouldBe` ["\""]
parseCmdLine "\"\\\"\""
`shouldBe` ["\""]
it "doesn't escape random characters" $
parseCmdLine "\\a\\b\\c"
`shouldBe` ["\\a\\b\\c"]
it "squashes multiple spaces" $
parseCmdLine "test command"
`shouldBe` ["test", "command"]