-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7f8940
commit 4d6e9b1
Showing
2 changed files
with
43 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from io import StringIO | ||
|
||
from xdsl.utils.base_printer import BasePrinter | ||
|
||
|
||
def test_indented(): | ||
output = StringIO() | ||
printer = BasePrinter(stream=output) | ||
printer.print_string("\n{") | ||
with printer.indented(): | ||
printer.print_string("\nhello\nhow are you?") | ||
printer.print_string("\n(") | ||
with printer.indented(): | ||
printer.print_string("\nfoo,") | ||
printer.print_string("\nbar,") | ||
printer.print_string("\n") | ||
printer.print_string("test\nraw print!", indent=0) | ||
printer.print_string("\ndifferent indent level", indent=4) | ||
printer.print_string("\n)") | ||
printer.print_string("\n}") | ||
printer.print_string("\n[") | ||
with printer.indented(amount=3): | ||
printer.print_string("\nbaz") | ||
printer.print_string("\n]\n") | ||
|
||
EXPECTED = """ | ||
{ | ||
hello | ||
how are you? | ||
( | ||
foo, | ||
bar, | ||
test | ||
raw print! | ||
different indent level | ||
) | ||
} | ||
[ | ||
baz | ||
] | ||
""" | ||
|
||
assert output.getvalue() == EXPECTED |