@@ -30,13 +30,27 @@ def test_replace_all():
3030
3131def test_rule_repl_cond ():
3232 for str_expr , str_expected , message in (
33- ("f[x]/.(f[u_]->u^2/; u>3/; u>2)" , "f[x]" , "conditions are not evaluated" ),
34- ("f[4]/.(f[u_]->u^2/; u>3/; u>2)" , "16" , "both conditions are True" ),
33+ # For Rules, replacement is not evaluated
3534 (
36- "f[2.5]/.(f[u_]->u^2/; u>3/; u>2)" ,
35+ "f[x]/.(f[u_]->u^2/; u>3/; u>2)" ,
36+ "x^2/; x>3/; x>2" ,
37+ "conditions are not evaluated in Rule" ,
38+ ),
39+ (
40+ "f[4]/.(f[u_]->u^2/; u>3/; u>2)" ,
41+ "16 /; 4 > 3 /; 4 > 2" ,
42+ "still not evaluated, even if values are provided, due to the HoldAll attribute." ,
43+ ),
44+ # However, for delayed rules, the behavior is different:
45+ # Conditions defines if the rule is applied
46+ # and do not appears in the result.
47+ ("f[x]/.(f[u_]:>u^2/; u>3/; u>2)" , "f[x]" , "conditions are not evaluated" ),
48+ ("f[4]/.(f[u_]:>u^2/; u>3/; u>2)" , "16" , "both conditions are True" ),
49+ (
50+ "f[2.5]/.(f[u_]:>u^2/; u>3/; u>2)" ,
3751 "f[2.5]" ,
3852 "just the first condition is True" ,
3953 ),
40- ("f[1.]/.(f[u_]- >u^2/; u>3/; u>2)" , "f[1.]" , "Both conditions are False" ),
54+ ("f[1.]/.(f[u_]: >u^2/; u>3/; u>2)" , "f[1.]" , "Both conditions are False" ),
4155 ):
4256 check_evaluation (str_expr , str_expected , message )
0 commit comments