From 2c2a96c8a7f2b11656951a4b4175447d3445968f Mon Sep 17 00:00:00 2001 From: "Johan B.W. de Vries" Date: Sun, 25 May 2025 14:21:25 +0200 Subject: [PATCH] Added some more missing test cases for promotable --- .../test_typeclasses/test_promotable.py | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/integration/test_typeclasses/test_promotable.py b/tests/integration/test_typeclasses/test_promotable.py index 82f29dc..26f3123 100644 --- a/tests/integration/test_typeclasses/test_promotable.py +++ b/tests/integration/test_typeclasses/test_promotable.py @@ -1,3 +1,5 @@ +import math + import pytest from phasm.type3.entry import Type3Exception @@ -23,18 +25,20 @@ def testEntry(x: Foo) -> Baz: Suite(code_py).run_code() @pytest.mark.integration_test -def test_promote_ok(): +@pytest.mark.parametrize('in_val, exp_val', [ + (10.5, 10.5, ), + (9.999999616903162e+35, 9.999999616903162e+35, ), +]) +def test_promote_ok(in_val, exp_val): code_py = """ -CONSTANT: f32 = 10.5 - @exported -def testEntry() -> f64: - return promote(CONSTANT) +def testEntry(x: f32) -> f64: + return promote(x) """ - result = Suite(code_py).run_code() + result = Suite(code_py).run_code(in_val) - assert 10.5 == result.returned_value + assert exp_val == result.returned_value @pytest.mark.integration_test def test_demote_not_implemented(): @@ -54,15 +58,18 @@ def testEntry(x: Foo) -> Baz: Suite(code_py).run_code() @pytest.mark.integration_test -def test_demote_ok(): +@pytest.mark.parametrize('in_val, exp_val', [ + (10.5, 10.5, ), + (9.999999616903162e+35, 9.999999616903162e+35, ), + (1e39, math.inf, ), +]) +def test_demote_ok(in_val, exp_val): code_py = """ -CONSTANT: f64 = 10.5 - @exported -def testEntry() -> f32: - return demote(CONSTANT) +def testEntry(x: f64) -> f32: + return demote(x) """ - result = Suite(code_py).run_code() + result = Suite(code_py).run_code(in_val) - assert 10.5 == result.returned_value + assert exp_val == result.returned_value