Added some more missing test cases for promotable
This commit is contained in:
parent
b670bb02ad
commit
2c2a96c8a7
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user