-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from tonicebrian/indent_combinator
Provide Indent combinator
- Loading branch information
Showing
4 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package gnieh.pp.tests | ||
|
||
import gnieh.pp._ | ||
|
||
class IndentTest extends PpTest { | ||
"the indent operator" should "indent text as block" in { | ||
val docs: List[Doc] = List("line1", "line2", "line3") | ||
val finalDoc = indent(2)(vcat(docs)) | ||
|
||
render80(finalDoc) should be(" line1\n line2\n line3") | ||
} | ||
it should "behave as original Haskell implementation" in { | ||
val doc = indent(4)(fillSep(words("the indent combinator indents these words !"))) | ||
|
||
val expectedRender = | ||
""" the indent | ||
| combinator | ||
| indents these | ||
| words !""".stripMargin | ||
|
||
render20(doc) should be(expectedRender) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters