{-# LANGUAGE OverloadedStrings #-} -- | -- -- Some test cases ported from Rust: -- -- module ShellWords.QuoteSpec ( spec ) where import Prelude hiding (truncate) import ShellWords.Quote (join, quote) import Test.Hspec spec :: Spec spec = do describe "quote" $ do it "single-quotes the empty string" $ do quote "" `shouldBe` "''" it "escapes a single quote" $ do quote "'" `shouldBe` "''\\'''" it "leaves un-special characters alone" $ do quote "abc" `shouldBe` "abc" it "quotes newlines" $ do quote "a \n b" `shouldBe` "'a \n b'" it "quotes newlines and escapes single-quotes" $ do quote "X'\nY" `shouldBe` "'X'\\''\nY'" it "quotes tildes correctly" $ do quote "~root" `shouldBe` "'~root'" describe "join" $ do it "joins arguments" $ do join ["a", "b", "c"] `shouldBe` "a b c" it "quotes arguments" $ do join [" ", "$", "\n"] `shouldBe` "' ' '$' '\n'"