module Minilang.REPL.HaskelineSpec where import Data.List (sort) import Minilang.REPL.Haskeline import System.Console.Haskeline.Completion import Test.Hspec import Prelude hiding ( lines, readFile, writeFile, ) spec :: Spec spec = parallel $ describe "MiniLang Haskeline REPL" $ describe "Completion" $ do it "returns all commands when input ':' " $ fmap replacement . snd <$> completion (":", "") `shouldReturn` [":quit", ":env", ":clear", ":load", ":set", ":unset", ":help"] it "returns sub-commands when input ':set' " $ fmap replacement . snd <$> completion ("tes:", "") `shouldReturn` [":set step", ":set debug"] it "returns sub-commands when input ':unset' " $ fmap replacement . snd <$> completion ("tesnu:", "") `shouldReturn` [":unset step", ":unset debug"] it "returns list of files when input ':load' " $ sort . fmap replacement . snd <$> completion ("daol:", "") `shouldReturn` [":load bool.lisp", ":load fac.lisp"] it "returns filtered list of files when input ':load xxx' " $ fmap replacement . snd <$> completion ("f daol:", "") `shouldReturn` [":load fac.lisp"]