Skip to content

Commit 0b7bcc4

Browse files
committed
Extend /; testing
1 parent 1a47243 commit 0b7bcc4

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

test/test_control.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010

11-
def test_control():
11+
def test_catch():
1212
session.evaluate(
1313
"""
1414
(* Define a function that can "throw an exception": *)
@@ -67,6 +67,38 @@ def test_control():
6767
"a",
6868
"Catch picks up the first Throw that is evaluated (2)",
6969
),
70+
):
71+
check_evaluation(str_expr, str_expected, message)
72+
7073

74+
def test_condition():
75+
session.evaluate(
76+
"""
77+
(* Define a function that can "throw an exception": *)
78+
79+
f[x_] := ppp[x]/; x>0
80+
"""
81+
)
82+
for str_expr, str_expected, message in (
83+
(
84+
"f[5]",
85+
"ppp[5]",
86+
"/; with True condition",
87+
),
88+
(
89+
"f[-6]",
90+
"f[-6]",
91+
"/; with False condition",
92+
),
93+
(
94+
"{6, -7, 3, 2, -1, -2} /. x_ /; x < 0 -> w",
95+
"{6, w, 3, 2, w, w}",
96+
"Replace all exlements which satisfy the condition of being negative",
97+
),
98+
(
99+
"{6, -7, 3, 2, -1, -2} /. x_ /; x < 0 -> w",
100+
"{6, w, 3, 2, w, w}",
101+
"Replace all elements which satisfy the condition of being negative",
102+
),
71103
):
72104
check_evaluation(str_expr, str_expected, message)

0 commit comments

Comments
 (0)