Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/interfaces/tests.py
8814 views
1
"""
2
TESTS:
3
4
We test coercions::
5
6
sage: 2 * gp('2')
7
4
8
sage: a = 2 * gp('2'); a
9
4
10
sage: parent(a)
11
PARI/GP interpreter
12
sage: a = 2 * gap('2'); a
13
4
14
sage: parent(a)
15
Gap
16
sage: a = 2 * maxima('2'); a
17
4
18
sage: parent(a)
19
Maxima
20
sage: a = 2 * singular('2'); a
21
4
22
sage: parent(a)
23
Singular
24
25
Test that write errors to stderr are handled gracefully by GAP
26
(see :trac:`13211`) and ECL (see :trac:`14426`) and other interfaces::
27
28
sage: import subprocess
29
sage: try:
30
....: f = open('/dev/full', 'w')
31
....: except IOError:
32
....: f = open('/dev/null', 'w')
33
sage: kwds = dict(shell=True, stdout=f, stderr=f)
34
sage: subprocess.call("echo syntax error | ecl", **kwds)
35
0
36
sage: subprocess.call("echo syntax error | gap", **kwds)
37
0
38
sage: subprocess.call("echo syntax error | gp", **kwds)
39
0
40
sage: subprocess.call("echo syntax error | ipython", **kwds) in (0,1)
41
True
42
sage: subprocess.call("echo syntax error | singular", **kwds)
43
0
44
"""
45
46
from all import *
47
from sage.misc.misc import cputime, walltime
48
import sys
49
50
def manyvars(s, num=70000, inlen=1, step=2000):
51
"""
52
Test that > 65,000 variable names works in each system.
53
"""
54
print "Testing -- %s"%s
55
t = '"%s"'%('9'*int(inlen))
56
try:
57
t = cputime()
58
w = walltime()
59
v = []
60
for i in range(num):
61
if i%step==0:
62
sys.stdout.write('%s '%i)
63
sys.stdout.flush()
64
v.append(s(t))
65
print '\nsuccess -- time = cpu: %s, wall: %s'%(cputime(t), walltime(w))
66
except Exception:
67
print "%s -- failed!"%s
68
69
def manyvars_all(num=70000):
70
#for s in [gap, gp, singular, kash, magma, octave, maxima, mathematica]:
71
for s in [kash, magma, octave, maxima, mathematica]:
72
manyvars(s, num)
73
74
# bad: maple -- infinite loop -- exception pexpect.EOF: <pexpect.EOF instance at 0xb091250c> in ignored
75
76
def manyvars_all2(num=70000):
77
for s in [singular, maxima, mathematica, octave]:
78
manyvars(s, num)
79
80