Skip to content

Commit

Permalink
Update test_haskell.py
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS committed Jun 1, 2020
1 parent 2e5f04f commit 59efd5f
Showing 1 changed file with 4 additions and 50 deletions.
54 changes: 4 additions & 50 deletions tests/interpreters/test_haskell.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_dependable_condition():

expr = ast.IfExpr(bool_test, ast.NumVal(1), ast.FeatureRef(0))

expected_code_1 = """
expected_code = """
module Model where
score :: [Double] -> Double
score input =
Expand All @@ -80,31 +80,10 @@ def test_dependable_condition():
else
(input) !! (0)
"""
expected_code_2 = """
module Model where
score :: [Double] -> Double
score input =
func1
where
func1 =
if (((func0) + (2)) >= ((1) / (2)))
then
1
else
(input) !! (0)
func0 =
if ((1) == (1))
then
1
else
2
"""

interpreter = HaskellInterpreter()
actual_code = interpreter.interpret(expr)
# dicts in Python 3.5 have nondeterministic order of keys
utils.assert_code_equal_any_of(
actual_code, expected_code_1, expected_code_2)
utils.assert_code_equal(actual_code, expected_code)


def test_nested_condition():
Expand All @@ -124,7 +103,7 @@ def test_nested_condition():

expr = ast.IfExpr(bool_test, expr_nested, ast.NumVal(2))

expected_code_1 = """
expected_code = """
module Model where
score :: [Double] -> Double
score input =
Expand All @@ -147,35 +126,10 @@ def test_nested_condition():
else
2
"""
expected_code_2 = """
module Model where
score :: [Double] -> Double
score input =
func1
where
func1 =
if ((1) == ((func0) + (2)))
then
if ((1) == ((func0) + (2)))
then
(input) !! (2)
else
2
else
2
func0 =
if ((1) == (1))
then
1
else
2
"""

interpreter = HaskellInterpreter()
actual_code = interpreter.interpret(expr)
# dicts in Python 3.5 have nondeterministic order of keys
utils.assert_code_equal_any_of(
actual_code, expected_code_1, expected_code_2)
utils.assert_code_equal(actual_code, expected_code)


def test_raw_array():
Expand Down

0 comments on commit 59efd5f

Please sign in to comment.