|
10 | 10 | import pytest |
11 | 11 |
|
12 | 12 |
|
13 | | -@pytest.mark.skipif( |
14 | | - sys.platform in ("win32", "emscripten") or hasattr(sys, "pyston_version_info"), |
15 | | - reason="TimeConstrained needs to be rewritten", |
16 | | -) |
| 13 | +# @pytest.mark.skipif( |
| 14 | +# sys.platform in ("win32", "emscripten") or hasattr(sys, "pyston_version_info"), |
| 15 | +# reason="TimeConstrained needs to be rewritten", |
| 16 | +# ) |
17 | 17 | def test_timeremaining(): |
18 | 18 | str_expr = "TimeConstrained[1+2; TimeRemaining[], 0.9]" |
19 | 19 | result = evaluate(str_expr) |
20 | 20 | assert result is None or 0 < result.to_python() < 9 |
21 | 21 |
|
22 | 22 |
|
23 | | -@pytest.mark.skip(reason="TimeConstrained needs to be rewritten") |
| 23 | +# @pytest.mark.skip(reason="TimeConstrained needs to be rewritten") |
24 | 24 | def test_timeconstrained1(): |
25 | 25 | # |
26 | | - str_expr1 = "a=1.; TimeConstrained[Do[Pause[.1];a=a+1,{1000}],1]" |
| 26 | + str_expr1 = "a=1.; TimeConstrained[Do[Pause[.01];a=a+1,{1000}],.1]" |
27 | 27 | result = evaluate(str_expr1) |
28 | 28 | str_expected = "$Aborted" |
29 | 29 | expected = evaluate(str_expected) |
30 | 30 | assert result == expected |
31 | 31 | time.sleep(1) |
32 | | - assert evaluate("a").to_python() == 10 |
| 32 | + assert evaluate("a").to_python() < 10 |
33 | 33 |
|
34 | 34 |
|
35 | 35 | def test_datelist(): |
@@ -109,6 +109,34 @@ def test_datestring(): |
109 | 109 | "Thu 6 Jun 1991 00:00:00", |
110 | 110 | "Specified separators", |
111 | 111 | ), |
| 112 | + ## |
| 113 | + ( |
| 114 | + "TimeConstrained[Integrate[Sin[x]^100,x],.5]", |
| 115 | + None, |
| 116 | + "$Aborted", |
| 117 | + "TimeConstrained with two arguments", |
| 118 | + ), |
| 119 | + ( |
| 120 | + "TimeConstrained[Integrate[Sin[x]^100,x],.5, Integrate[Cos[x],x]]", |
| 121 | + None, |
| 122 | + "Sin[x]", |
| 123 | + "TimeConstrained with three arguments", |
| 124 | + ), |
| 125 | + ( |
| 126 | + "a=.;s=TimeConstrained[Integrate[Sin[x] ^ 3, x], a]", |
| 127 | + ( |
| 128 | + "Number of seconds a is not a positive machine-sized number or Infinity.", |
| 129 | + ), |
| 130 | + "TimeConstrained[Integrate[Sin[x] ^ 3, x], a]", |
| 131 | + "TimeConstrained unevaluated because the second argument is not numeric", |
| 132 | + ), |
| 133 | + ( |
| 134 | + "a=1; s", |
| 135 | + None, |
| 136 | + "Cos[x] (-3 + Cos[x] ^ 2) / 3", |
| 137 | + "s is now evaluated because `a` is a number.", |
| 138 | + ), |
| 139 | + ("a=.;s=.;", None, "Null", None), |
112 | 140 | ], |
113 | 141 | ) |
114 | 142 | def test_private_doctests_datetime(str_expr, msgs, str_expected, fail_msg): |
|
0 commit comments