Skip to content

Commit

Permalink
tests/llvm: Don't check newline encoding in the printf test
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
  • Loading branch information
jvesely committed Jun 7, 2023
1 parent 1582baa commit 31d65ae
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/llvm/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ def test_helper_all_close(mode, var1, var2, atol, rtol):
(pnlvm.ir.DoubleType(), "%lf", [x *.5 for x in range(0, 5)]),
], ids=["i32", "i64", "double"])
def test_helper_printf(capfd, ir_argtype, format_spec, values_to_check):
format_str = f"Hello {(format_spec+' ')*len(values_to_check)} \n"

format_str = f"Hello {(format_spec + ' ') * len(values_to_check)}\n"

with pnlvm.LLVMBuilderContext.get_current() as ctx:
func_ty = ir.FunctionType(ir.VoidType(), [])
ir_values_to_check = [ir_argtype(i) for i in values_to_check]
Expand All @@ -252,8 +254,11 @@ def test_helper_printf(capfd, ir_argtype, format_spec, values_to_check):

# Convert format specifier to Python compatible
python_format_spec = {"%lld":"%ld"}.get(format_spec, format_spec)
python_format_str = f"Hello {(python_format_spec+' ')*len(values_to_check)} \n"
assert capfd.readouterr().out == python_format_str % tuple(values_to_check)

# The string below omits the newline character used above and the check below
# uses 'startswith' to avoid issues with different newline encoding across OSes.
python_format_str = f"Hello {(python_format_spec + ' ') * len(values_to_check)}"
assert capfd.readouterr().out.startswith(python_format_str % tuple(values_to_check))

class TestHelperTypegetters:
FLOAT_TYPE = pnlvm.ir.FloatType()
Expand Down

0 comments on commit 31d65ae

Please sign in to comment.