Skip to content

Commit

Permalink
Don't use empty output delimiters unless requested
Browse files Browse the repository at this point in the history
In particular, while input delimiters are usually used for the default
output delimiters, setting empty input delimiters to specify the
line-based or the stream based input format should not cause the output
delimiters to be empty.
  • Loading branch information
gelisam committed Feb 15, 2015
1 parent e485bbb commit 83f1c9e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 3 additions & 2 deletions runtime/System/Console/Hawk/Args/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ data Separator = Whitespace | Delimiter Delimiter
deriving (Show, Eq)

fromSeparator :: Separator -> Delimiter
fromSeparator Whitespace = " "
fromSeparator (Delimiter d) = d
fromSeparator Whitespace = " "
fromSeparator (Delimiter "") = " "
fromSeparator (Delimiter d) = d


newtype ContextSpec = ContextSpec
Expand Down
2 changes: 1 addition & 1 deletion src/System/Console/Hawk/Args/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ inputSpec (rSep, fSep) = InputSpec <$> source <*> format
--
-- >>> test ["-D;", "-d", "-a", "L.reverse"]
-- UseStdout
-- (";","")
-- (";"," ")
--
-- >>> test ["-o\t", "-d,", "-O|"]
-- UseStdout
Expand Down
19 changes: 19 additions & 0 deletions tests/System/Console/Hawk/PreludeTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ testEval flags expr = test flags expr ""
-- parse error (possibly incorrect indentation or mismatched brackets)
-- *** Exception: ExitFailure 1
--
-- Making sure that setting line-mode or stream-mode doesn't affect the output format
-- unless specifically requested:
--
-- >>> testPrelude "default" ["-d", "-m"] "\\x -> ('a', x, 'b')" "1-3"
-- a 1 b
-- a 2 b
-- a 3 b
--
-- >>> testPrelude "default" ["-d", "-o", "-m"] "\\x -> ('a', x, 'b')" "1-3"
-- a1b
-- a2b
-- a3b
--
-- >>> testPrelude "default" ["-D", "-a"] "\\x -> ('a', x, 'b')" "equation"
-- a x1*y1*z1 + x2*y2*z2 b
--
-- >>> testPrelude "default" ["-D", "-O", "-a"] "\\x -> ('a', x, 'b')" "equation"
-- ax1*y1*z1 + x2*y2*z2b
--
-- Making sure that we don't assume the user prelude exports "map":
--
-- >>> testPrelude "set" ["-m"] "const $ \"hello\"" "1-3"
Expand Down

0 comments on commit 83f1c9e

Please sign in to comment.