Skip to content

Commit

Permalink
move test
Browse files Browse the repository at this point in the history
  • Loading branch information
superlopuh committed Dec 10, 2024
1 parent d7f8940 commit 4d6e9b1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
40 changes: 0 additions & 40 deletions tests/test_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,43 +952,3 @@ def test_get_printed_name():
printed = StringIO()
picked_name = Printer(printed).print_ssa_value(val)
assert f"%{picked_name}" == printed.getvalue()


def test_indented():
output = StringIO()
printer = Printer(stream=output)
printer.print("\n{")
with printer.indented():
printer.print("\nhello\nhow are you?")
printer.print("\n(")
with printer.indented():
printer.print("\nfoo,")
printer.print("\nbar,")
printer.print("\n")
printer.print_string("test\nraw print!", indent=0)
printer.print_string("\ndifferent indent level", indent=4)
printer.print("\n)")
printer.print("\n}")
printer.print("\n[")
with printer.indented(amount=3):
printer.print("\nbaz")
printer.print("\n]\n")

EXPECTED = """
{
hello
how are you?
(
foo,
bar,
test
raw print!
different indent level
)
}
[
baz
]
"""

assert output.getvalue() == EXPECTED
43 changes: 43 additions & 0 deletions tests/utils/test_base_printer.py
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

0 comments on commit 4d6e9b1

Please sign in to comment.