File Coverage

test_eng/Testout.pm
Criterion Covered Total %
statement 346 451 76.7
branch 125 208 60.1
condition 65 101 64.3
subroutine 42 48 87.5
pod n/a
total 578 808 71.5


line stmt bran cond sub pod time code
1             #! perl
2             # $rcs = ' $Id: testout.t,v 1.2 1997/09/22 10:13:37 ilya Exp ilya $ ' ;
3              
4 22     22   8958 use strict;
  22         37  
  22         647  
5 22     22   10470 use Math::Pari qw(:DEFAULT pari_print :all);
  22         51  
  22         139  
6 20     20   297 use vars qw($x $y $z $k $t $q $a $u $i $j $l $name $other $n);
  20         61  
  20         16301  
7             die "Need a path to a testout file" unless @ARGV;
8              
9             my $file = CORE::shift;
10             my(@tests, %seen, $current_num, $userfun, $installed, $skip_gnuplot, %not_yet_defined, $printout, $intests, $rest, $popped);
11             {
12             open TO, "< $file" or die "open `$file': $!";
13             local $/ = "\n? ";
14             @tests = ;
15             close TO or die "close: $!";
16             }
17              
18             my $mess = '';
19             $mess = CORE::shift @tests if @tests and $tests[0] !~ /^\?/; # Messages
20             my @skip_fun;
21             my $skip_fun_rx = qr/(?!)/;
22             my $matched_par;
23             $matched_par = qr[[^()]*(?:\((??{$matched_par})\)[^()]*)*]; # arbitrary string with ( and ) matching
24             my %ourvars;
25             my $ourvars_rx = qr/(?!)/;
26             my $skipvars_rx = qr/(?!)/;
27              
28             my $can_matrix = eval {PARImat_tr([[3]]) == matrix(1, 1, my $x, my $y, sub{3})} ; # after 2.3.5, but before support
29             my $or_matrix = (not $can_matrix and "|matrix");
30             my $or_matrix_out = (not $can_matrix and " (or matrix())");
31              
32             (my $ifile = $file) =~ s[(?<=/test/)(32|64)/][in/];
33             {
34             open FROM, '<', $ifile or die "open `$file': $!";
35             local $/;
36             $intests = ;
37             close FROM or die "close: $!";
38             }
39             my $pref;
40             ($pref = $intests) =~ s/^(\\e|default\(echo,[^\n]*\n)(.*)//ms and CORE::length $pref and $rest = $2;
41              
42             $popped++, pop @tests if ($tests[-1] || 0) =~ /^\\q/;
43              
44             my $skip_eval = (Math::Pari::pari_version_exp() >= 2004002);
45             my $use_dollars_in_argsign = $skip_eval;
46              
47             if ($pref =~ /^\s*\\\\\s*package:(.*)/m) {
48             print "1..0 # skipped: package dependency: $1\n";
49             @tests = ();
50             } elsif (my $tests = @tests) {
51             $tests += !!$rest;
52             print "1..$tests\n";
53             } elsif ($rest) {
54             print "1..1\nnot ok 1 # no tests found in `$file', but input has echo enabled\n";
55             warn "unexpected format of GP/PARI test output file: echo enabled, but no echoed lines";
56             } else { # no echoed lines expected
57             print "1..0 # skipped: command-line echoing is not enabled in the test file `$ifile'\n";
58             }
59              
60             # prec($3 || $1, 1) if $mess =~ /.*realprecision = (\d+) significant digits( \((\d+) digits displayed\))?/; # take the latest one
61             if ($rest) { # 'define'
62             (my $Pref = $pref) =~ s/^(.*)$/### $1/mg ;
63             print("# The following `? ' are the output from parse_as_gp() for\n$Pref");
64             my $Err;
65             eval { parse_as_gp $pref, sub ($) {"main::".CORE::shift}, 'echo'; 1}
66             or $Err = $@;
67             $current_num++;
68             if (defined $Err) { # failed to process, but do emit the expected-for-test output
69             print "not ok $current_num # in no-echo group err=$Err\n";
70             } else {
71             print "ok $current_num # Skipping translation to Math::Pari (no-echo group done in PARI, see above)\n";
72             }
73             }
74             $rest ||= $intests;
75              
76             #Math::Pari::dumpStack,allocatemem(8e6),Math::Pari::dumpStack if $file =~ /intnum/; # Due to our allocation policy we need more?
77              
78              
79             $| = 1; # Need to list loop variables used by the code:
80             my @seen = qw(Euler Pi I getrand a x xx y z k t q u j l n v p e s
81             name other mhbi a2 a1 a0 b0 b1
82             acurve bcurve ccurve cmcurve tcurve mcurve ma mpoints);
83             my @VARS = map "\$$_", @seen;
84 20     20   120 eval 'use vars @VARS; 1' or die "use vars: $@";
  20         27  
  20         2468  
85             @seen{@seen} = (' ', ' ', ' ', ' ', ('$') x 100);
86             $seen{oo} = ' ' if Math::Pari::pari_version_exp >= 2009000;
87             for (@seen) {
88 20     20   132 no strict 'refs';
  20         31  
  20         76609  
89             $$_ = PARI($_) unless $seen{$_} eq ' ';
90             }
91             $seen{'random'} = ' ';
92             my $DEFAULT = undef;
93              
94             # Some of these are repeated below (look for XXXX), since they cause
95             # an early interpretation of unquoted args
96             @not_yet_defined{qw(
97             type
98             )} = (1) x 10000;
99              
100             if ($file =~ /plot|graph|all/) {
101             if ($ENV{MP_NOGNUPLOT}) {
102             $skip_gnuplot = 1;
103             } else {
104             eval { link_gnuplot() };
105             if ($@ =~ m%^Can't locate Term/Gnuplot.pm in \@INC%) {
106             print STDERR "# Can't locate Term/Gnuplot.pm in \@INC, ignoring plotting\n";
107             @not_yet_defined{qw(
108             plotbox plotcolor plotcursor plotdraw ploth plothraw plotinit plotlines
109             plotmove plotpoints plotrline plotrmove plotrpoint psdraw psploth
110             psplothraw plotscale
111             plotkill
112             )} = (1) x 10000;
113             $skip_gnuplot = 1;
114             } elsif ($@) {
115             die $@;
116             }
117             }
118             }
119              
120             my $started = 0;
121              
122             main_loop:
123             while (@tests) {
124             $_ = CORE::shift @tests;
125             #print "Doing `$_'";
126             1 while s/^\\\\.*\n//; # Comment
127             my $bad = /^\\(?!p[bs]?\s*\d)/; # \precision =
128             my $wasbadprint = /\b(plot)\b/;
129             my $wasprint = /\b((|p|tex)print(tex)?|plot)\b/;
130             s/\s*\n\?\s*\Z// or not $popped or die "Not terminated: `$_'\n";
131             s/\A(\s*\?)+\s*//;
132             # s/[^\S\n]+$//gm;
133             s/\A(.*)\s*; $ \s*(\w+)\s*\(/$1;$2(/mx; # Continuation lines of questions
134             # Special-case tests nfields-3 and intnum-23 with a wrapped question:
135             s/\A(p2=.*\d{10})\n(7\n)/$1$2/;
136             s/\n(?=\/\w)//;
137             s/\A(.*)\s*$//m or die "No question: `$_'\n";
138             my $in = $1;
139             1 while s/^\n//; # Before warnings
140             1 while s/^\s*\*+\s*warning.*\n?//i; # skip warnings
141             if (s/^\s*\*+\s*(.*)//) { # error
142             process_error($in,$_,$1);
143             next;
144             }
145             process_test($in, 'noans', []), next if /^$/; # Was a void
146             # s/^%\d+\s*=\s*// or die "Malformed answer: $_" unless $bad or $wasprint;
147             if ($_ eq '' or $wasprint) { # Answer is multiline
148             # @ans = $_ eq '' ? () : ($_) ;
149             # while (<>) {
150             # last if /^\?\s+/;
151             # next if /^$/;
152             # chomp;
153             # push @ans, $_;
154             # }
155             my @ans = split "\n";
156             if ($wasbadprint) {
157             process_print($in, @ans);
158             } elsif ($wasprint) {
159             process_test($in, 'print', [@ans]);
160             } else {
161             process_test($in, 0, [@ans]);
162             }
163             next main_loop;
164             }
165             if ($bad) {
166             process_set($in, $_);
167             } else {
168             process_test($in, 0, [$_]);
169             }
170             }
171              
172             sub format_matrix {
173 43     43   110 my $in = CORE::shift;
174 43         122 my @in = split /;/, $in;
175 43         220 'PARImat_tr([[' . join('], [', @in) . ']])';
176             }
177              
178             sub format_vvector {
179 5     5   13 my $in = CORE::shift;
180 5         10 $in =~ s/~\s*$//;
181 5         34 "PARIcolL($in)";
182             }
183              
184             sub re_format { # Convert PARI output to a regular expression
185 585     585   1201 my $in = join "\n", @_;
186 585         1330 $in = quotemeta $in;
187 585         1237 $in =~ s/\\\]\\\n\\\n\\\[/\\s*;\\s*/g; # row separator
188 585         1253 $in =~ s/\\\n/\\s*/g;
189 585         6416 $in =~ s/\\[ \t]/,?\\s*/g;
190             # This breaks a lot of linear.t tests
191             ### Allow for rounding 3999999 <=> 40000000, but only after . or immediately before it
192             ##$in =~ s/([0-8])((?:\\\.)?)(9+(\\s\*9+)?)(?![+\d])/$n=$1+1;"($1$2$3|$n${2}0+)"/ge;
193             ##$in =~ s/([1-9])((?:\\\.)?)(0+(\\s\*0+)?)(?![+\d])/$n=$1-1;"($1$2$3|$n${2}9+)"/ge;
194             ##$in =~ s/(\d{8,})([1-8])(?![+\d()]|\\s\*)/$n=$2-1;$m=$2+1;$1."[$2$n$m]\\d*"/ge;
195 585         1265 $in
196             }
197              
198             sub mformat {
199             # if not matrix, join with \t
200 80 50 33 80   363 return join("\t", @_) unless @_ > 1 and $_[0] =~ /^\[/;
201 1         2 @_ = grep {!/^$/} @_; # remove empty lines
  1         19  
202 1 0       6 return join("\t", @_) if grep {!/^\s*\[.*\]\s*$/} @_; # Not matrix
  1         1  
203             #return join("\t", @_) if grep {!/^\s*\([^,]*,\s*$/} @_; # Extra commas
204 1         23 map {s/^\s*\[\s*(.*?)\s*\]\s*$/$1/} @_;
  1         8  
205 1         3 my @arr = map { join ', ', split } @_;
  1         20  
206 1         8 '[' . join('; ', @arr) . ']';
207             }
208              
209             sub mformat_transp {
210 1 0 0 1   2 return join("\t", @_) unless @_ > 1 and $_[0] =~ /^\[/;
211 1         21 @_ = grep {!/^$/} @_;
  1         6  
212 1 0       1 return join("\t", @_) if grep {!/^\s*\[.*\]\s*$/} @_; # Not matrix
  1         22  
213             #return join("\t", @_) if grep {!/^\s*\([^,]*,\s*$/} @_; # Extra commas
214 1         7 map {s/^\s*\[(.*)\]\s*$/$1/} @_;
  1         1  
215 1         20 my @arr = map { [split] } @_;
  1         6  
216 1         1 my @out;
217 1         21 my @dummy = ('') x @{$arr[0]};
  1         6  
218 1         2 for my $ind (0..$#{$arr[0]}) {
  1         20  
219 1         8 for my $subarr (@arr) {
220 1 0       2 @$subarr > $ind or $subarr->[$ind] = '';
221             }
222 1         25 push @out, join ', ', map {$_->[$ind]} @arr;
  1         7  
223             }
224 1         2 '[' . join('; ', @out) . ']';
225             }
226              
227             sub massage_floats {
228 161     161   244 my $in = CORE::shift;
229 161   100     371 my $pre = CORE::shift || "16g";
230 161         1145528 $in =~ s/(.\d*)\s+e/$1E/gi; # 1.74 E-78
231 161         916 $in =~ s/\b(\d+\.\d*(e[-+]?\d+)?|\d{10,})\b/sprintf "%.${pre}", $1/gei;
  4751         23890  
232 161         466 $in;
233             }
234              
235             sub o_format {
236 13     13   71 my ($var,$power) = @_;
237 12 100       55 return " PARI('O($var^$power)') " if defined $power;
238 1         5 return " PARI('O($var)') ";
239             }
240              
241             sub process_cond {
242 9     10   49 my ($what, $cond, $then, $else, $initial) = @_;
243 9 100       50 die if $initial =~ /Skip this/;
244             # warn "Converting `$in'\n`$what', `$cond', `$then', `$else'\n";
245 8 100       21 if (($what eq 'if') ne (defined $else)) {
    100          
246 1         11 return "Skip this `$initial'";
247             } elsif ($what eq 'if') {
248 5         48 return "( ($cond) ? ($then) : ($else) )";
249             } else {
250 2         20 return "do { $what ($cond) { $then } }";
251             }
252             }
253              
254             sub nok_print {
255 0     1   0 my ($n, $in) = (CORE::shift, CORE::shift);
256 0 0       0 print(@_), return unless $ENV{AUTOMATED_TESTING};
257 0         0 warn("# in = `$in'\n", @_);
258 0         0 print("not ok $n\n");
259             }
260              
261             sub update_seen ($) {
262 669     670   937 my $seen_now = CORE::shift;
263 669         1847 @seen{keys %$seen_now} = values %$seen_now;
264             # my @VARS = map "\$$_", keys %$seen_now;
265             # eval 'use vars @VARS; 1' or die "use vars: $@";
266             }
267              
268             sub pre_update_seen ($) {
269 94     95   139 my $sym = CORE::shift;
270             # @seen{keys %$seen_now} = values %$seen_now;
271             # my @VARS = map "\$$_", keys %$seen_now;
272 94 50   9   5511 eval "use vars '\$$sym'; 1" or die "use vars: $@";
  9     6   52  
  9     6   18  
  9     6   192  
  6     6   38  
  6     6   9  
  6     6   146  
  6     4   35  
  6     3   9  
  6     3   124  
  6     3   34  
  6     3   8  
  6     3   131  
  6     3   33  
  6         12  
  6         122  
  6         37  
  6         17  
  6         161  
  6         35  
  6         8  
  6         141  
  4         24  
  4         6  
  4         94  
  3         20  
  3         4  
  3         70  
  3         26  
  3         4  
  3         72  
  3         20  
  3         3  
  3         72  
  3         19  
  3         6  
  3         68  
  3         19  
  3         6  
  3         80  
  3         19  
  3         5  
  3         73  
273             }
274              
275             sub subify_iterators ($$) {
276 121     122   295 my($pre, $code, $subargs, $subdecl) = (CORE::shift, CORE::shift, '', '');
277 121 50       217 if ($use_dollars_in_argsign) {
278 0         0 $subargs = ' ($) ';
279 0 0       0 if ($pre =~ /^(v?vector|fordiv|sumdiv|plothexport)\(/) {
280 0 0       0 $pre =~ /^\w+\s*\([^,]*,\s*([\$\w]+)\s*,/ or die "Cannot find iterator variable in `$pre\{\{\{$code\}\}\}'";
281 0         0 $subdecl = "my $1 = CORE::shift;"
282             } else {
283 0 0       0 $pre =~ /^\w+\s*\(\s*([\$\w]+)\s*,/ or die "Cannot find iterator variable in `$pre\{\{\{$code\}\}\}'";
284 0         0 $subdecl = "my $1 = CORE::shift;"
285             }
286             }
287             # /$1 sub$subargs\{$2}/xg;
288 121         3243 "$pre sub$subargs\{$subdecl$code\}";
289             }
290              
291             sub filter_res ($) { # In PARI’s Mod() output there is an extra space comparing to ours
292 150     151   515 my $r = CORE::shift;
293 150         172 $r =~ s/(\bmatrix\([^\s,]+)\s+/$1,/g;
294             # warn "### ->\t$r\n";
295 150 50       487 return $r unless $r =~ /\bMod\(/;
296 0         0 $r =~ s/,\s+/,/g;
297 0         0 return $r;
298             }
299              
300             my $prev;
301             sub process_test {
302 736     737   1402 my ($in, $noans, $out) = @_;
303             # warn("<<<$in>>>, $noans, <<<@$out>>>");
304 736         1097 my($IN, $res, $rres, $rout) = $in;
305 736         778 my $ini_time = time;
306 736         604 my $doprint;
307 736 100       1072 $doprint = 1 if $noans eq 'print';
308 736         669 my $was_prev = $prev;
309 736         767 undef $prev;
310 736         855 $current_num++;
311             # First a trivial processing:
312 736         938 $in =~ s/^\s*gettime\s*;//; # Starting lines of tests...
313 736         821 $in =~ s/\b(\d+|[a-z]+\(\))\s*\\\s*(\d+(\^\d+)?)/ gdivent($1,$2)/g; # \
314 736         795 $in =~ s/\b(\d+)\s*\\\/\s*(\d+)/ gdivround($1,$2)/g; # \/
315 736         792 $in =~ s/\b(\w+)\s*!/ ifact($1)/g; # !
316 736         1231 $in =~ s/,\s*(?=,)/, \$DEFAULT /g; # Default arguments?
317 736         724 $in =~ s/^default\(realprecision,(.*)\)/\\p $1/; # Some cases of default()
318 736         657 $in =~ s/^default\(realbitprecision,(.*)\)/\\pb $1/; # Some cases of default()
319 736         704 $in =~ s/^default\(seriesprecision,(.*)\)/\\ps $1/; # Some cases of default()
320 736         728 $in =~ s/(\w+)\s*\\(\w+(\s*\^\s*\w+)?)/gdivent($1,$2)/g; # random\10^8
321 736         726 $in =~ s/%(?!\s*[\[_\w])/\$was_prev/g; # foo(%)
322 736         765 $in =~ s/\b(for)\s*\(\s*(\w+)=/&$1($2,/g; # for(x=1,13,print(x))
323 736         743 $in =~ s/
324             ^
325             (
326             \(
327             (?:
328             [^(,)]+
329             (?=
330             [(,)]
331             )
332             |
333             \( [^()]* \)
334             )* # One level of parenths supported
335             \)
336             )
337             ' $
338             /deriv$1/x; # ((x+y)^5)'
339 736 100 100     4775 if ($in =~ /^\\p\s*(\d+)/) {
    50          
    100          
    50          
    50          
    50          
340 15         58 prec("$1");
341             } elsif ($in =~ /^\\pb\s*(\d+)/) { # \\ for division unsupported
342 0         0 bprec("$1");
343             } elsif ($in =~ /^\\ps\s*(\d+)/) { # \\ for division unsupported
344 1         3 sprec("$1");
345             } elsif ($in =~ /\\/) { # \\ for division unsupported
346 0         0 $current_num--;
347 0         0 process_error($in, $out, '\\');
348             } elsif ($in =~ /^(\w+)\s*\([^()]*\)\s*=/ and 0) { # XXXX Not implemented yet
349 0         0 $current_num--;
350 0         0 process_definition($1, $in);
351             } elsif ($in =~ /!(?![\(\w])|\'/) { # Factorial (unless in !foo())
352 0         0 print "# `$in'\nok $current_num # Skipping (ifact/deriv)\n";
353             } else {
354             # work with "^", need to treat differently inside o()
355 720         1138 $in =~ s/\^/^^^/g;
356 720         1749 $in =~ s/\bo\(([^()^]*)(\^\^\^([^()]*))?\)/ o_format($1,$3) /gei;
  12         29  
357 720         972 $in =~ s/\^\^\^/**/g; # Now treat it outside of O()
358 720         924 $in =~ s/\[([^\[\];]*;[^\[\]]*)\]/format_matrix($1)/ge; # Matrix
  42         80  
359 720         886 $in =~ s/\[([^\[\];]*)\]\s*~/format_vvector($1)/ge; # Vertical vector
  4         10  
360 720         759 eval {
361 720         1833 1 while $in =~ s/
362             \b (if|while|until) \(
363             (
364             (?:
365             [^(,)]+
366             (?=
367             [(,)]
368             )
369             |
370             \( [^()]* \)
371             )* # One level of parenths supported
372             )
373             ,
374             (
375             (?:
376             [^(,)]+
377             (?=
378             [(,)]
379             )
380             |
381             \( [^()]* \)
382             )* # One level of parenths supported
383             )
384             (?:
385             ,
386             (
387             (?:
388             [^(,)]+
389             (?=
390             [(,)]
391             )
392             |
393             \( [^()]* \)
394             )* # One level of parenths supported
395             )
396             )?
397             \)
398 9         22 /process_cond($1, $2, $3, $4, $in)/xge; # if(a,b,c)
399             };
400 720         745 my $RET;
401 720 50 100     27384 if ($in =~ /\[[^\]]*;/) { # Matrix
    100 100        
    50          
    50          
    100          
    100          
    100          
    100          
    100          
    50          
    50          
402 0         0 print "# `$in'\nok $current_num # Skipping (matrix notation)\n";
403 0         0 $RET = 1;
404             } elsif ($in =~ /Skip this `(.*)'/) {
405 1         28 print "# `$1'\nok $current_num # Skipping (runaway conversion)\n";
406 1         3 $RET = 1;
407             } elsif ($in =~ /&for\s*\([^\)]*$/) { # Special case
408 0         0 print "# `$in'\nok $current_num # Skipping (runaway input line)\n";
409 0         0 $RET = 1;
410             } elsif ($in =~ /(^|[\(=,])%/) {
411 0         0 print "# `$in'\nok $current_num # Skipping (history notation)\n";
412 0         0 $RET = 1;
413             } elsif ($in =~ /\b(get(heap|stack)|Total time spent.*gettime)\b/) {
414 26         799 print "# `$in'\nok $current_num # Silently skipping: meaningless for Math::Pari\n";
415 26         70 $RET = 1;
416             } elsif ($in =~ /
417             (
418             \b
419             ( if | goto | label | input | break
420             # | while | until
421             | gettime | default
422             )
423             \b
424             |
425             (\w+) \s* \( \s* (?: (?!\d)\w+ \s* (?:, \s* (?!\d)\w+ \s* )* )? \) \s* =(?!=)
426             |
427             \b install \s* \( \s* (\w+) \s* , [^()]* \)
428             |
429             \b
430             (
431             my _
432             )?
433             (?: p? print $or_matrix ) \(
434             ( \[ | (1 ,)? PARImat )
435             | # Too many parens: will not be wrapped in sub{...}
436             \b forprime .* \){5}
437             )
438             /x) {
439 9 100       23 if (defined $3) {
440 4         35 print "# User function `$3'.\n";
441             }
442 9 100       27 if (defined $4) {
443 1 50       3 if (defined $installed) {
444 0         0 $installed .= "|$4";
445             } else {
446 1         1 $installed = $4;
447             }
448 1         9 print "# Installed function `$4'.\n";
449             }
450 9 50 33     25 if ($1 eq 'default' and $in =~ /^default\s*\(\s*echo\s*,\s*0\s*\)\s*(;\s*)?$/) { # See the test 'ff' - but this is not present in the OUTPUT!!!???
451 0 0       0 if ($rest =~ s/\A.*?^default\s*\(\s*echo\s*,\s*0\s*\)\s*(;\s*)?$//ms) { # Try to matchin in $rest:
452 0 0       0 if ($rest =~ s/\A(.*?)^default\s*\(\s*echo\s*,\s*(?!0\b)\S[^\n]*\)\s*(;\s*)?$//ms) {
453 0         0 (my $Pref = my $cmd = "$1") =~ s/^(.*)$/### $1/mg ;
454 0 0 0     0 if ($cmd =~ /(?:^|;)\s*(?:print|error)\(/ or $userfun and $cmd =~ / \b ($userfun) \s* \( /x) {
      0        
455 0         0 my $with = '';
456 0 0       0 if ($cmd =~ /^\s*(\w+)\s*\($matched_par\)\s*=(?!=)/) {
457 0         0 $with = "with a user function $1() ";
458 0 0       0 if (defined $userfun) {
459 0         0 $userfun .= "|$1";
460             } else {
461 0         0 $userfun = $1;
462             }
463             }
464 0         0 print "${Pref}ok $current_num # Skipping (no-echo group ${with}containing print() or error() or a converted-to-Perl variable)\n";
465             } else {
466 0         0 print("# The following `? ' are the output from parse_as_gp() for\n$Pref");
467 0         0 my $Err;
468 0 0   1   0 eval { parse_as_gp $cmd, sub ($) {"main::".CORE::shift}, 'echo'; 1}
  0         0  
  0         0  
  0         0  
469             or $Err = $@;
470             # next # fail to process, but do emit the expected-for-test output
471 0 0       0 if (defined $Err) {
472 0         0 print "# `$in'\nnot ok $current_num # in no-echo group err=$Err\n";
473             } else {
474 0         0 print "# `$in'\nok $current_num # Skipping translation to Math::Pari (no-echo group done in PARI, see above)\n";
475             }
476             }
477 0         0 $RET = 1;
478             } else {
479 0         0 warn("Cannot find a matching echo-on command in input file"),
480             }
481             } else {
482 0         0 warn("Cannot find a matching echo-off command in input file"),
483             }
484             } else {
485             # It is not clear why changevar gives a different answer in GP
486 9         105 print "# `$in'\nok $current_num # Skipping (converting test for '$1' needs additional work)\n";
487 9         23 $RET = 1;
488             }
489             } elsif ($userfun
490             and $in =~ / \b ($userfun) \s* \( /x) {
491 1         13 print "# `$in'\nok $current_num # Skipping (user function containing print() or error() $or_matrix_out or a converted-to-Perl variable)\n";
492 1         4 $RET = 1;
493             } elsif ($installed
494             and $in =~ / \b ($installed) \s* \( /x) {
495 1         10 print "# `$in'\nok $current_num # Skipping (installed function)\n";
496 1         3 $RET = 1;
497             # } elsif ($in =~ / \b ( sizebyte ) \b /x
498             # and $file !~ /will_fail/) {
499             # # XXXX Will result in a wrong answer, but we moved these tests to a different
500             # print "# `$in'\nok $current_num # Skipping (would fail, checked in different place)\n";
501             # $RET = 1;
502             } elsif ($in =~ /\b(nonesuch now|nfisincl$or_matrix)\b/) {
503 2         42 print "# `$in'\nok $current_num # Skipping (possibly FATAL $1)\n";
504 2         7 $RET = 1;
505             } elsif ($in =~ /\$?\b($skipvars_rx)\b/) {
506 0         0 print "# `$in'\nok $current_num # Skipping (a variable `$1' was possibly defined in a skipped statement)\n";
507 0         0 $RET = 1;
508             } elsif ($in =~ $skip_fun_rx) {
509 0         0 print "# `$in'\nok $current_num # Skipping (see a PARI function $1() calling print() or error())\n";
510 0         0 $RET = 1;
511             }
512             # Convert transposition
513 720         1273 $in =~ s/(\$?\w+(\([^()]*\))?|\[([^\[\]]+(?=[\[\]])|\[[^\[\]]*\])*\])~/mattranspose($1)/g;
514             # Convert strings with a simple word
515 720 100       1342 $in =~ s/("\w+")/'$1'/g unless $in =~ /\b(my_)?print\b/; # XXX Silly ad hoc trick (temporary???)
516 720 50       1101 if ($in =~ /~/) {
517 0         0 print "# `$in'\nok $current_num # Skipping (transpose notation)\n";
518 0         0 $RET = 1;
519             }
520 720 50       1027 if ($in =~ /->/) {
521 0         0 print "# `$in'\nok $current_num # Skipping (-> notation)\n";
522 0         0 $RET = 1;
523             }
524 720 100       983 if ($RET) {
525 40         134 while ($in =~ /(?:^|;)\$?(\w+)=(?!=)/g) {
526 5         21 $skipvars_rx .= "|$1";
527             }
528             }
529 720 100 100     1175 if ($RET and $in =~ /(?:^|;)\$?(\w+)\([^()]*\)=(?!=)/) {
530 4         9 my $n = $1;
531 4 100       114 if ($in =~ /\b(print|error|$ourvars_rx)\b/) {
532 1         4 push @skip_fun, $n;
533 1         2 my $rx = join '|', @skip_fun;
534 1         10 $skip_fun_rx = qr/\b($rx)\(/;
535 1 50       4 if ($1 eq 'print') {
536 0         0 print "# NOT doing PARI-eval: print() seen\n";
537             } else {
538 1         9 print "# NOT doing PARI-eval: variable `$1' converted to Perl before was seen\n";
539             }
540 1 50       5 if (defined $userfun) {
541 0         0 $userfun .= "|$n";
542             } else {
543 1         2 $userfun = $n;
544             }
545 1         6 return;
546             }
547 3         26 print "# doing PARI-eval of a function `$n' instead\n";
548 3         69 PARI $IN;
549 20     20   193 no strict 'refs';
  20         36  
  20         1731  
550 3         18 *$n = Math::Pari::__wrap_PARI_macro $n;
551             }
552 719 100       1027 return if $RET;
553 680 100       1053 if ($in =~ /^\s*alias\s*\(\s*(\w+)\s*,\s*(\w+)\s*\)$/) {
554 1         12 print "# Aliasing `$1' ==> `$2'\nok $current_num\n";
555 20     20   106 no strict 'refs';
  20         32  
  20         77526  
556 1         2 *$1 = \&{$2};
  1         7  
557 1         5 return;
558             }
559 679 100       3839 if ($in !~ /\w\(/) { # No function calls
    100          
560             # XXXX Primitive!
561             # Constants: (.?) eats following + or - (2+3 ==> PARI(2)+PARI(3))
562 25         217 $in =~ s/(^|\G|\W)([-+]?)(\d+(\.\d*)?(?:e-?\d+)?)(.?)/$1 $2 PARI($3) $5/gi;
563             # Big integer constants:
564 25         56 $in =~ s/\bPARI\((\d{10,})\)/PARI('$1')/g;
565             } elsif ($in =~ /\b(elllseries|binomial|mathilbert|intnum|intfuncinit|intfuncinit)\b|\bint\w/) { # high precision needed?
566             # XXXX Primitive!
567             # Substitute constants where they are not arguments to functions,
568             # (except small half-integers, which should survive conversion)
569 45         195 $in =~ s/(^|\G|[^\w''])([-+]?)(?!\d{0,6}\.5\b)(\d+\.\d*(?:e-?\d+)?)/$1 $2 PARI('$3') /gi;
570             # The precision of 4.5 in intfuncinit(t=[-oo, 4.5],[oo, 4.5], gamma(2+I*t)^3, 1) may be less than current precision;
571 45 100       230 $in =~ s/(^|\G|[^\w''])([-+]?)(\d+\.\d*(?:e-?\d+)?)/$1 $2 PARI('$3') /gi
572             if $in =~ /\bint\w/;
573 45         160 $in =~ s/((?
574             # Big integer constants:
575 45         79 $in =~ s/\bPARI\((\d{10,})\)/PARI('$1')/g;
576             } else {
577             # Substitute big integer constants
578 609         2790 $in =~ s/(^|\G|\W)(\d{10,}(?!\.\d*(?:e-?\d+)?))(.?)/$1 PARI('$2') $3/gi;
579             # Substitute division
580 609         936 $in =~ s/(^|[\-\(,\[=+*\/])(\d+)\s*\/\s*(\d+)(?=$|[*+\-\/\),\]])/$1 PARI($2)\/PARI($3) /g;
581             }
582 679         701 my %seen_now;
583             # Substitute i= in loop commands
584 679 100       1895 if ($in !~ /\b(hermite|mathnf|until)\s*\(/) { # Special case, not loop-with-=
585 674         1003 $in =~ s/([\(,])(\w+)=(?!=)/ $seen_now{$2} = '$'; "$1$2," /ge;
  72         240  
  72         281  
586             }
587             # Substitute print
588 679         818 $in =~ s/\b(|p|tex)print(tex|)\(/ 'my_' . $1 . $2 . 'print(1,' /ge;
  17         52  
589 679         707 $in =~ s/\b(|p|tex)print1\(/ 'my_' . $1 . 'print(0,'/ge;
  6         16  
590 679 50 33     1122 if ($skip_eval and $in =~ /\beval\(/g) { # eval($y)
591 0         0 print("# `$in'\nok $current_num # Skipping: eval's signature C is not supported yet\n"), return;
592             }
593 679         1219 $in =~ s/\b(eval|shift|sort)\(/&$1\(/g; # eval($y)
594             # Special case -oo (with $oo=[PARI(1)] done earlier;
595             # Having $oo defined without external PARI tests conversions; but it'sn't overloaded in older PARI
596 679 50 33     3051 $in =~ s/-oo\b/- PARI(\$oo)/ if $seen_now{oo} or Math::Pari::pari_version_exp < 2009000;
597             # Recognize variables and prepend $ in assignments
598             # s/\b(direuler\s*\(\s*\w+\s*),/$1=/; # direuler
599 679 100       1103 $in =~ s/\bX\b/PARIvar("X")/g if $in =~ /\bdireuler\b/;
600 679         3541 $in =~ s/(^\s*|[;(]\s*)(?=(\w+)\s*=\s*)/$seen_now{$2} = '$'; pre_update_seen($2); $1 . '$'/ge; # Assignment
  94         257  
  94         177  
  94         856  
601 679 50       1212 if ($in =~ /\.((?!\d|(?<=\d\.)e-?\d)\w+(?![\w"]))/) {
602 0         0 print("# `$in'\nok $current_num # Skipping: methods not supported yet (.$1)\n"), return;
603             }
604 679 50       980 if ($in =~ /(?
605 0         0 print("# `$in'\nok $current_num # Skipping: |var<- not supported yet\n"), return;
606             }
607             # Prepend $ to variables (not before '^' - inside of 'o(x^17)'):
608 679         3580 $in =~ s/(^|[^\$])\b([a-zA-Z]\w*)\b(?!\s*[\(^])/
609 996   100     5317 ($1 || '') . ($seen{$2} || $seen_now{$2} || '') . $2
      100        
610             /ge;
611             # Skip if did not substitute variables:
612 679         4501 while ($in =~ /(^|[^\$])\b([a-zA-Z]\w*)\b(?!\s*[\{\(^])/g) {
613             print("# `$in'\nok $current_num # Skipping: variable `$2' was not set\n"), return
614 78 100 66     584 unless $seen{$2} and $seen{$2} eq ' ' or $in =~ /\"/;
      100        
615             # Let us hope that lines which contain '"' do not contain unset vars
616             }
617             # Simplify for the following conversion:
618 677         923 $in =~ s/\brandom\(\)/random/g;
619             # Sub-ify sum,prod,intnum* sumnum etc, psploth, ploth etc
620 677         1770 my $oneArg = qr/(?: # 3 levels of parentheses supported
621             [^(,)\[\]]+
622             (?=
623             [(,)\[\]]
624             )
625             |
626             \( # One level of parenths
627             (?:
628             [^()]+
629             (?=
630             [()]
631             )
632             |
633             \( # Second level of parenths
634             (?:
635             [^()]+
636             (?=
637             [()]
638             )
639             | \( [^()]* \) # Third level of parens
640             )*
641             \) # Second level of parenths ends
642             )*
643             \)
644             |
645             \[ # One level of brackets
646             (?:
647             [^\[\]]+
648             (?=
649             [\[\]]
650             )
651             |
652             \[ [^\[\]]+ \] # Second level of brackets
653             )*
654             \]
655             )* # 3 levels of parenths supported
656             /x;
657 677         14621 1 while
658             $in =~ s/ (
659             \b
660             (?:
661             (?: # For these, sub{}ify the fourth argument
662             sum
663             |
664             intnum(?!init\b)\w*
665             |
666             intfuncinit
667             |
668             int\w*inv
669             |
670             intcirc\w*
671             |
672             sumnum(?!init\b)\w*
673             |
674             forprime
675             |
676             psploth
677             |
678             ploth
679             |
680             prod (?: euler )?
681             |
682             direuler
683             ) \s*
684             \( (?: $oneArg [=,] ){3} # $x,1,100
685             | (?: # For these, sub{}ify the third argument
686             sumalt
687             |
688             prodinf
689             ) \s*
690             \( (?: $oneArg [=,] ){2} # $x,1
691             | (?: # For these, sub{}ify the fifth argument
692             plothexport
693             ) \s*
694             \( (?: $oneArg [=,] ){4} # "ps",$x,100
695             | ( # 2: For these, sub{}ify the last argument
696             solve
697             |
698             (?:
699             post
700             )?
701             ploth (?! raw (?:export)? \b | sizes \b | export \b ) \w+
702             |
703             # sum \w*
704             sum (?! alt | num (?:init)? \b) \w+
705             |
706             v? vector v?
707             |
708             matrix
709             |
710             intgen
711             |
712             intopen
713             |
714             for \w*
715             ) \s*
716             \( (?: $oneArg , )* # "ps",$x,1,100; do not accept "=" after the iterator variable
717             )
718             ) # end group 1
719             (?!\s*sub(?:\s*\(\$*\))?\s*\{) # Skip already converted...
720             ( $oneArg ) # 3: This follows after a comma on toplevel
721             (?(2) (?= \) ) | (?= [),] ) )
722 121         558 /subify_iterators("$1","$3")/xge;
723             # Convert 10*20 to integer
724 677         1660 $in =~ s/(\d+)(?=\*\*\d)/ PARI($1) /g;
725             # Convert blah[3], blah()[3] to blah->[-1+3]
726 677         884 $in =~ s/([\w\)])\[/$1 -> [-1+/g;
727             # Fix [,3] converted to [-1+,3]
728 677         784 $in =~ s/\[-1\+,/\[-1+/g;
729             # Fix [2,3] converted to [-1+2,3]
730 677         737 $in =~ s/\[(-1\+[^,\[\]\(\)]+),([^\(\)\[\]]+)\]/\[-1+$2\]\[$1\]/g;
731             # Workaround for &eval test:
732 677         676 $in =~ s/\$y=\$x;&eval\b(.*)/PARI('y=x');&eval$1;\$y=\$x/;
733 677         674 $in =~ s/\$yy=\$xx;&eval\b(.*)/PARI('yy=xx');&eval$1;\$yy=\$xx/;
734             # Workaround for hardly-useful support for &:
735 677 100       952 if ($in =~ s/([,\(]\s*)&(\$(\w+)\s*)(?=[,\)])/$1$2/) {
736             #$in = qq(\$$3 = PARI "'$3"; \$OUT = do { $in }; \$$3 = PARI "$3"; \$OUT)
737             }
738             # Workaround for kill:
739 677         664 $in =~ s/^kill\(\$(\w+)\);/kill('$1');\$$1=PARIvar '$1';/;
740             # Workaround for plothsizes:
741 677         660 $in =~ s/\bplothsizes\(/safe_sizes(/;
742             # XXXX Silly workaround for `my' (probably a side effect of replacing "var=" by "var," in iterators???)
743 677         1802 $in =~ s/(?<=\bmy\(\$)(\w+),(?=\w+\()/$1)=(/g;
744 677 100       20213 print "# eval", ($noans ? "-$noans" : '') ,": $in\n";
745 677         1974 $printout = '';
746 677   100     6630 my $have_floats = ($in =~ /\d+\.\d*|\d{10,}/
747             or $in =~ /\b( ellinit|zeta|bin|comprealraw|frac|
748             lseriesell|powrealraw|legendre|suminf|
749             forstep )\b/x);
750 677         709 my $newvars;
751 677   66     1930 $ourvars{$1}++ or $newvars++ while $in =~ /(?
752 677 100       976 if ($newvars) {
753 75         700 $ourvars_rx = join '|', sort keys %ourvars;
754 75         2888 $ourvars_rx = qr($ourvars_rx);
755             }
756             # Remove the value from texprint:
757             # pop @$out if $in =~ /texprint/ and @$out == 2;
758 677         988 my $pre_time = time() - $ini_time;
759 677         42021 $res = eval "$in";
760 677         3817 my $run_time = time() - $ini_time - $pre_time;
761 677         1126 $rres = $res;
762 677 100 100     568177 $rres = pari_print $res if defined $res and ref $res;
763 677         931 my $re_out;
764 677 100       1070 if ($doprint) {
765 14 50       29 if ($in =~ /my_texprint/) { # Special-case, assume one wrapped with \n
766 0         0 $rout = join "", @$out, "\t";
767             } else {
768 14         31 $rout = join "\t", @$out, "";
769             }
770 14 100       25 if ($have_floats) {
771 1         3 $printout = massage_floats $printout, "14f";
772 1         2 $rout = massage_floats $rout, "14f";
773             }
774             # New wrapping code gets in the way:
775 14         147 $printout =~ s/\s+/ /g;
776 14         22 $rout =~ s/\t,/,/g;
777 14         72 $rout =~ s/\s+/ /g;
778              
779 14         26 $rout =~ s/,\s*/, /g;
780 14         19 $printout =~ s/,\s*/, /g;
781 14         71 $rout =~ s/\s*([-+])\s*/ $1 /g;
782 14         53 $printout =~ s/\s*([-+])\s*/ $1 /g;
783             } else {
784             # Special-case several tests in all.t
785 663 100 100     3231 if (($have_floats or $in =~ /^(sinh?|solve)\b/) and ref $res) {
      100        
786             # do it the hard way: we cannot massage floats before doing wrapping
787 79         199 $rout = mformat @$out;
788 79 50 33     403 if (defined $rres and $rres !~ /\n/) {
789 79         198 $rout =~ s/\]\s*\[/; /g;
790 79         124 $rout =~ s/\[\s+/[/g;
791 79         153 $rout =~ s/,\n/, \n/g; # Spaces were removed
792 79         215 $rout =~ s/\n//g; # Long wrapped text
793             }
794 79 100 100     308 if ($rout =~ /\[.*[-+,;]\s/ or $rout =~ /\bQfb\b/) {
795 24         1013 $rout =~ s/,*\s+/ /g;
796 24 50       748 $rres =~ s/,*\s+/ /g if defined $res;
797 24 50       131 $rres =~ s/,/ /g if defined $res; # in 2.2.10 ", "
798 24         66 $rout =~ s/;\s*/; /g; # in 2.2.10 "; "
799 24 50       73 $rres =~ s/;\s*/; /g if defined $res; # in 2.2.10 "; "
800             }
801 79 100       384 if ($in =~ /\b(zeta|bin|comprealraw|frac|lseriesell|powrealraw|pollegendre|legendre|suminf|ellinit)\b/) {
802 17         45 $rres = massage_floats $rres, "14f";
803 17         33 $rout = massage_floats $rout, "14f";
804             } else {
805 62         128 $rres = massage_floats $rres;
806 62         112 $rout = massage_floats $rout;
807             }
808 79         348 $rout =~ s/\s*([-+])\s*/$1/g;
809 79 50       2445 $rres =~ s/\s*([-+])\s*/$1/g if defined $res;
810             } else {
811 584         1237 $re_out = re_format @$out;
812             # $rout = mformat @$out;
813             # if (defined $rres and $rres !~ /\n/) {
814             # $rout =~ s/\]\s*\[/; /g;
815             # $rout =~ s/,\n/, \n/g; # Spaces were removed
816             # $rout =~ s/\n//g; # Long wrapped text
817             # }
818             # if ($rout =~ /\[.*[-+,;]\s/) {
819             # $rout =~ s/,*\s+/ /g;
820             # $rres =~ s/,*\s+/ /g if defined $res;
821             # }
822             # $rout =~ s/\s*([-+])\s*/$1/g;
823             # $rres =~ s/\s*([-+])\s*/$1/g if defined $res;
824             }
825             }
826              
827 677 100       1192 if ($@) {
828 8 50 33     50 if ($@ =~ /^Undefined subroutine &main::(\w+)/
    50 33        
    50 33        
    50          
829             and $not_yet_defined{$1}) {
830 0         0 print "# in='$in'\nok $current_num # Skipped: `$1' is known to be undefined\n";
831             } elsif ($@ =~ /high resolution graphics disabled/
832             and 0 >= Math::Pari::have_graphics()) {
833 0         0 print "# in='$in'\nok $current_num # Skipped: graphic is disabled in this build\n";
834             } elsif ($@ =~ /pari_daemon without waitpid & setsid is not yet implemented/) {
835 0         0 print "# in='$in'\nok $current_num # Skipped: graphic (pari_daemon) is disabled in this build\n";
836             } elsif ($@ =~ /gnuplot-like plotting environment not loaded yet/
837             and $skip_gnuplot) {
838 8         209 print "# in='$in'\nok $current_num # Skipped: Term::Gnuplot is not loaded\n";
839             } else { # XXXX Parens needed???
840 0         0 nok_print( $current_num, $in, "not ok $current_num # in='$in', err='$@'\n" );
841             }
842 8         69 return;
843             }
844 669         648 my $cmp;
845 669 100 100     1815 if (defined $rres and defined $re_out) {
846 547         822 for my $how (0,'Mat') {
847 578         691 my $RR = $rres;
848 578 100       2432 $RR =~ s/\bMat\(($matched_par)\)/[$1]/g if $how;
849 578         635 $cmp = eval { $RR =~ /^$re_out$/ };
  578         19328  
850 578 50 33     1399 if ($@ and $@ =~ /regexp too big/) {
851 0         0 print "ok $current_num # Skipped: $@\n";
852 0         0 update_seen \%seen_now;
853 0         0 $prev = $res;
854 0         0 return;
855             }
856 578 100       1071 last if $cmp
857             }
858             }
859 669         921 my $post_time = time() - $ini_time - $pre_time - $run_time;
860 669 50 100     4110 if (not $noans and defined $re_out
    100 33        
    50 66        
    50 100        
      33        
      66        
      66        
861             and (not defined $rres or not $cmp)) {
862 0         0 $out->[0] =~ s/\n/\t/g; # @$out usually has 1 elt
863 0         0 nok_print $current_num, $in, "not ok $current_num # in='$in'\n# out='", $rres, "', type='", ref $res,
864             "'\n# pari==='", join("\t", @$out), "'\n# re_out='$re_out'\n";
865             } elsif (not $noans and defined $re_out) {
866 516         18639 print "ok $current_num # run_time=$run_time, post_time=$post_time, pre_time=$pre_time\n";
867 516         2168 update_seen \%seen_now;
868 516         4945 $prev = $res;
869             } elsif (not $noans and (not defined $rres or filter_res $rres ne filter_res $rout)) {
870 0         0 nok_print $current_num, $in, "not ok $current_num # in='$in'\n# out='", $rres, "', type='", ref $res,
871             "'\n# expect='$rout'\n";
872             } elsif ($doprint and $printout ne $rout) {
873 0         0 nok_print $current_num, $in, "not ok $current_num # in='$in'\n# printout='", $printout,
874             "'\n# expect='$rout', type='", ref $res,"'\n";
875             } else {
876 153         7164 print "ok $current_num # run_time=$run_time, post_time=$post_time, pre_time=$pre_time\n";
877 153         687 update_seen \%seen_now;
878 153         1764 $prev = $res;
879             }
880             }
881             }
882              
883             sub process_error {
884 3     4   11 my ($in, $out, $error) = @_;
885 3         5 $current_num++;
886 3         32 print("# `$in'\nok $current_num # Skipping: test producing PARI error unsupported yet (err=$error)\n");
887             }
888              
889             sub process_definition {
890 0     0   0 my ($name, $def) = @_;
891 0         0 $current_num++;
892 0         0 eval "PARI('$def'); import Math::Pari $name;";
893 0 0       0 if ($@) {
894 0         0 chomp $@;
895 0         0 print("not ok $current_num # definition: `$def' error `$@'\n");
896             } else {
897 0         0 print("# definition $current_num: `$def'\nok $current_num\n");
898             }
899             }
900              
901             sub process_set {
902 0     0   0 my ($in, $out) = @_;
903 0 0       0 return process_test("setprecision($1)", 'noans', []) if $in =~ /^\\p\s*(\d+)$/;
904 0         0 $current_num++;
905 0         0 print("# `$in'\nok $current_num # Skipping setting test\n");
906             }
907              
908             sub process_print {
909 2     2   10 my ($in, @out) = @_;
910 2         4 $current_num++;
911 2         64 print("# $current_num: `$in'\nok $current_num # Skipping plot() - can't test it yet\n");
912             }
913              
914             sub process_multi {
915 0     0   0 my ($in, $out) = @_;
916 0         0 my @out = @$out;
917 0         0 $current_num++;
918 0         0 print("# `$in'\nok $current_num # Skipping multiline\n");
919             }
920              
921             sub my_print {
922 126     126   145 my $nl = CORE::shift;
923 126 100       139 @_ = map {(ref) ? (pari_print $_) : $_} @_;
  231         679  
924 126         198 $printout .= join '', @_;
925 126 100       162 $printout .= "\t" if $nl;
926 126         1511 return;
927             }
928              
929             sub my_pprint {
930 0     0   0 my $nl = CORE::shift;
931 0 0       0 @_ = map {(ref) ? (pari_pprint $_) : $_} @_;
  0         0  
932 0         0 $printout .= join '', @_;
933 0 0       0 $printout .= "\t" if $nl;
934 0         0 return;
935             }
936              
937             sub my_texprint {
938 0     0   0 my $nl = CORE::shift;
939 0 0       0 @_ = map {(ref) ? (pari_texprint $_) : $_} @_;
  0         0  
940 0         0 $printout .= join '', @_;
941 0 0       0 $printout .= "\t" if $nl;
942 0         0 return;
943             }
944              
945             sub prec {
946 15     15   84 setprecision($_[0]);
947 15         265 print "# Setting precision to $_[0] digits.\n";
948 15 50       319 print "ok $current_num\n" unless $_[1];
949             }
950             sub bprec {
951 0     0   0 PARI("default(realbitprecision,$_[0])"); # setbitprecision($_[0]);
952 0         0 print "# Setting bitprecision to $_[0] bits.\n";
953 0         0 print "# bitprecision: res=", PARI("default(realbitprecision)"),"\n";
954 0 0       0 print "ok $current_num\n" unless $_[1];
955             }
956             sub sprec {
957 1     1   4 setseriesprecision($_[0]);
958 1         9 print "# Setting series precision to $_[0] digits.\n";
959 1         11 print "ok $current_num\n";
960             }
961              
962             # *Need* to convert to PARI, otherwise the arithmetic will propagate
963             # the values to floats
964              
965 1 50   1   2 sub safe_sizes { eval {plothsizes()} or PARI [1000,1000,20,20,20,20]}
  1         102