1# -*- coding: utf-8 -*-
2from .helper import check_evaluation
3import pytest
4
5list_test_assumptions_integrate = [
6    (
7        "Integrate[x^n, {x, 0, 1}]",
8        "Piecewise[{{1 / (1 + n), 1 + Re[n] > 0 && n > -Infinity && n < Infinity && n != -1}}, Infinity]",
9        "This is so complicated due the sympy result is wrong...",
10    ),
11    (
12        "Assuming[0 < n < 1, Integrate[x^n, {x, 0, 1}]]",
13        "Piecewise[{{1 / (1 + n), 1 + Re[n] > 0 && n > -Infinity && n < Infinity && n != -1}}, Infinity]",
14        "",
15    ),
16    (
17        "Assuming[0 < Re[n] + 1, Integrate[x^n, {x, 0, 1}]]",
18        "Piecewise[{{1 / (1 + n), n > -Infinity && n < Infinity && n != -1}}, Infinity]",
19        "",
20    ),
21    ("Assuming[n == 1, Integrate[x^n, {x, 0, 1}]]", "1 / 2", ""),
22    ("Assuming[n == 2, Integrate[x^n, {x, 0, 1}]]", "1 / 3", ""),
23    ("Assuming[n == -1, Integrate[x^n, {x, 0, 1}]]", "Infinity", ""),
24    #    ("Assuming[1<n<3, Integrate[x^n, {x, 0, 1}]]", "x^(n+1)/(n+1)", ""),
25    #    ("Assuming[Or[n==1, n==2], Integrate[x^n, {x, 0, 1}]]", "x^(n+1)/(n+1)", ""),
26    #    ("Assuming[Or[n>2, n>=3], Integrate[x^n, {x, 0, 1}]]", "x^(n+1)/(n+1)", ""),
27]
28
29list_test_assumptions_simplify = [
30    ("Simplify[a==b || a!=b]", "True", "",),
31    ("Simplify[a==b && a!=b]", "False", "",),
32    ("Simplify[a<=b && a>b]", "False", "",),
33    ("Simplify[a==b, ! a!=b]", "True", "",),
34    ("Simplify[a==b,   a!=b]", "False", "",),
35    ("Simplify[a > b,  {a==4}]", "b < 4", "",),
36    ("Simplify[And[a>b, b<a]]", "a>b", "",),
37    ("Simplify[Or[a>b, a<b]]", "a!=b", "",),
38    ("Simplify[Or[a>b, b<a]]", "a>b", "",),
39    ("Simplify[a>b,  {b<=a}]", "a>b", "",),
40]
41
42
43@pytest.mark.parametrize(
44    ("str_expr", "str_expected", "message"), list_test_assumptions_integrate,
45)
46@pytest.mark.xfail
47def test_assumptions_integrate(str_expr, str_expected, message):
48    check_evaluation(str_expr, str_expected)
49
50
51@pytest.mark.parametrize(
52    ("str_expr", "str_expected", "message"), list_test_assumptions_simplify,
53)
54@pytest.mark.xfail
55def test_assumptions_simplify(str_expr, str_expected, message):
56    check_evaluation(str_expr, str_expected)
57