File Coverage

test_eng/Testout.pm
Criterion Covered Total %
statement 345 450 76.6
branch 125 208 60.1
condition 65 101 64.3
subroutine 42 48 87.5
pod n/a
total 577 807 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   8588 use strict;
  22         39  
  22         613  
5 22     22   10417 use Math::Pari qw(:DEFAULT pari_print :all);
  22         48  
  22         137  
6 20     20   152 use vars qw($x $y $z $k $t $q $a $u $i $j $l $name $other $n);
  20         26  
  20         15737  
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   123 eval 'use vars @VARS; 1' or die "use vars: $@";
  20         30  
  20         2429  
85             @seen{@seen} = (' ', ' ', ' ', ' ', ('$') x 100);
86             $seen{oo} = ' ' if Math::Pari::pari_version_exp >= 2009000;
87             for (@seen) {
88 20     20   127 no strict 'refs';
  20         28  
  20         75376  
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   77 my $in = CORE::shift;
174 43         113 my @in = split /;/, $in;
175 43         207 'PARImat_tr([[' . join('], [', @in) . ']])';
176             }
177              
178             sub format_vvector {
179 5     5   13 my $in = CORE::shift;
180 5         8 $in =~ s/~\s*$//;
181 5         32 "PARIcolL($in)";
182             }
183              
184             sub re_format { # Convert PARI output to a regular expression
185 585     585   1225 my $in = join "\n", @_;
186 585         1382 $in = quotemeta $in;
187 585         1265 $in =~ s/\\\]\\\n\\\n\\\[/\\s*;\\s*/g; # row separator
188 585         1303 $in =~ s/\\\n/\\s*/g;
189 585         6513 $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         1315 $in
196             }
197              
198             sub mformat {
199             # if not matrix, join with \t
200 80 50 33 80   413 return join("\t", @_) unless @_ > 1 and $_[0] =~ /^\[/;
201 1         2 @_ = grep {!/^$/} @_; # remove empty lines
  1         20  
202 1 0       5 return join("\t", @_) if grep {!/^\s*\[.*\]\s*$/} @_; # Not matrix
  1         2  
203             #return join("\t", @_) if grep {!/^\s*\([^,]*,\s*$/} @_; # Extra commas
204 1         20 map {s/^\s*\[\s*(.*?)\s*\]\s*$/$1/} @_;
  1         6  
205 1         3 my @arr = map { join ', ', split } @_;
  1         21  
206 1         6 '[' . join('; ', @arr) . ']';
207             }
208              
209             sub mformat_transp {
210 1 0 0 1   1 return join("\t", @_) unless @_ > 1 and $_[0] =~ /^\[/;
211 1         25 @_ = grep {!/^$/} @_;
  1         7  
212 1 0       1 return join("\t", @_) if grep {!/^\s*\[.*\]\s*$/} @_; # Not matrix
  1         23  
213             #return join("\t", @_) if grep {!/^\s*\([^,]*,\s*$/} @_; # Extra commas
214 1         8 map {s/^\s*\[(.*)\]\s*$/$1/} @_;
  1         2  
215 1         20 my @arr = map { [split] } @_;
  1         5  
216 1         2 my @out;
217 1         20 my @dummy = ('') x @{$arr[0]};
  1         5  
218 1         2 for my $ind (0..$#{$arr[0]}) {
  1         20  
219 1         6 for my $subarr (@arr) {
220 1 0       2 @$subarr > $ind or $subarr->[$ind] = '';
221             }
222 1         20 push @out, join ', ', map {$_->[$ind]} @arr;
  1         6  
223             }
224 1         2 '[' . join('; ', @out) . ']';
225             }
226              
227             sub massage_floats {
228 161     161   256 my $in = CORE::shift;
229 161   100     384 my $pre = CORE::shift || "16g";
230 161         1143829 $in =~ s/(.\d*)\s+e/$1E/gi; # 1.74 E-78
231 161         1214 $in =~ s/\b(\d+\.\d*(e[-+]?\d+)?|\d{10,})\b/sprintf "%.${pre}", $1/gei;
  4751         23156  
232 161         561 $in;
233             }
234              
235             sub o_format {
236 13     13   57 my ($var,$power) = @_;
237 12 100       61 return " PARI('O($var^$power)') " if defined $power;
238 1         5 return " PARI('O($var)') ";
239             }
240              
241             sub process_cond {
242 9     10   33 my ($what, $cond, $then, $else, $initial) = @_;
243 9 100       30 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         45 return "( ($cond) ? ($then) : ($else) )";
249             } else {
250 2         18 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   956 my $seen_now = CORE::shift;
263 669         1893 @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   137 my $sym = CORE::shift;
270             # @seen{keys %$seen_now} = values %$seen_now;
271             # my @VARS = map "\$$_", keys %$seen_now;
272 94 50   9   5033 eval "use vars '\$$sym'; 1" or die "use vars: $@";
  9     6   52  
  9     6   15  
  9     6   186  
  6     6   38  
  6     6   12  
  6     6   138  
  6     4   37  
  6     3   8  
  6     3   148  
  6     3   36  
  6     3   12  
  6     3   142  
  6     3   34  
  6         10  
  6         115  
  6         39  
  6         10  
  6         133  
  6         38  
  6         10  
  6         134  
  4         25  
  4         7  
  4         87  
  3         20  
  3         5  
  3         76  
  3         19  
  3         5  
  3         72  
  3         18  
  3         7  
  3         72  
  3         18  
  3         4  
  3         74  
  3         22  
  3         6  
  3         88  
  3         20  
  3         5  
  3         71  
273             }
274              
275             sub subify_iterators ($$) {
276 121     122   273 my($pre, $code, $subargs, $subdecl) = (CORE::shift, CORE::shift, '', '');
277 121 50       207 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         3294 "$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   216 my $r = CORE::shift;
293 150         208 $r =~ s/(\bmatrix\([^\s,]+)\s+/$1,/g;
294             # warn "### ->\t$r\n";
295 150 50       575 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   1385 my ($in, $noans, $out) = @_;
303             # warn("<<<$in>>>, $noans, <<<@$out>>>");
304 736         1025 my($IN, $res, $rres, $rout) = $in;
305 736         793 my $ini_time = time;
306 736         635 my $doprint;
307 736 100       1047 $doprint = 1 if $noans eq 'print';
308 736         686 my $was_prev = $prev;
309 736         811 undef $prev;
310 736         810 $current_num++;
311             # First a trivial processing:
312 736         1003 $in =~ s/^\s*gettime\s*;//; # Starting lines of tests...
313 736         775 $in =~ s/\b(\d+|[a-z]+\(\))\s*\\\s*(\d+(\^\d+)?)/ gdivent($1,$2)/g; # \
314 736         787 $in =~ s/\b(\d+)\s*\\\/\s*(\d+)/ gdivround($1,$2)/g; # \/
315 736         833 $in =~ s/\b(\w+)\s*!/ ifact($1)/g; # !
316 736         1207 $in =~ s/,\s*(?=,)/, \$DEFAULT /g; # Default arguments?
317 736         742 $in =~ s/^default\(realprecision,(.*)\)/\\p $1/; # Some cases of default()
318 736         679 $in =~ s/^default\(realbitprecision,(.*)\)/\\pb $1/; # Some cases of default()
319 736         712 $in =~ s/^default\(seriesprecision,(.*)\)/\\ps $1/; # Some cases of default()
320 736         752 $in =~ s/(\w+)\s*\\(\w+(\s*\^\s*\w+)?)/gdivent($1,$2)/g; # random\10^8
321 736         734 $in =~ s/%(?!\s*[\[_\w])/\$was_prev/g; # foo(%)
322 736         818 $in =~ s/\b(for)\s*\(\s*(\w+)=/&$1($2,/g; # for(x=1,13,print(x))
323 736         711 $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     4896 if ($in =~ /^\\p\s*(\d+)/) {
    50          
    100          
    50          
    50          
    50          
340 15         62 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         4 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         1112 $in =~ s/\^/^^^/g;
356 720         1818 $in =~ s/\bo\(([^()^]*)(\^\^\^([^()]*))?\)/ o_format($1,$3) /gei;
  12         29  
357 720         956 $in =~ s/\^\^\^/**/g; # Now treat it outside of O()
358 720         870 $in =~ s/\[([^\[\];]*;[^\[\]]*)\]/format_matrix($1)/ge; # Matrix
  42         75  
359 720         963 $in =~ s/\[([^\[\];]*)\]\s*~/format_vvector($1)/ge; # Vertical vector
  4         10  
360 720         743 eval {
361 720         1853 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         23 /process_cond($1, $2, $3, $4, $in)/xge; # if(a,b,c)
399             };
400 720         733 my $RET;
401 720 50 100     27738 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         37 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         942 print "# `$in'\nok $current_num # Silently skipping: meaningless for Math::Pari\n";
415 26         81 $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         37 print "# User function `$3'.\n";
441             }
442 9 100       24 if (defined $4) {
443 1 50       3 if (defined $installed) {
444 0         0 $installed .= "|$4";
445             } else {
446 1         2 $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         108 print "# `$in'\nok $current_num # Skipping (converting test for '$1' needs additional work)\n";
487 9         21 $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         11 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         30 print "# `$in'\nok $current_num # Skipping (possibly FATAL $1)\n";
504 2         6 $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         1245 $in =~ s/(\$?\w+(\([^()]*\))?|\[([^\[\]]+(?=[\[\]])|\[[^\[\]]*\])*\])~/mattranspose($1)/g;
514             # Convert strings with a simple word
515 720 100       1446 $in =~ s/("\w+")/'$1'/g unless $in =~ /\b(my_)?print\b/; # XXX Silly ad hoc trick (temporary???)
516 720 50       1400 if ($in =~ /~/) {
517 0         0 print "# `$in'\nok $current_num # Skipping (transpose notation)\n";
518 0         0 $RET = 1;
519             }
520 720 50       1053 if ($in =~ /->/) {
521 0         0 print "# `$in'\nok $current_num # Skipping (-> notation)\n";
522 0         0 $RET = 1;
523             }
524 720 100       1301 if ($RET) {
525 40         123 while ($in =~ /(?:^|;)\$?(\w+)=(?!=)/g) {
526 5         21 $skipvars_rx .= "|$1";
527             }
528             }
529 720 100 100     1178 if ($RET and $in =~ /(?:^|;)\$?(\w+)\([^()]*\)=(?!=)/) {
530 4         10 my $n = $1;
531 4 100       110 if ($in =~ /\b(print|error|$ourvars_rx)\b/) {
532 1         4 push @skip_fun, $n;
533 1         3 my $rx = join '|', @skip_fun;
534 1         9 $skip_fun_rx = qr/\b($rx)\(/;
535 1 50       5 if ($1 eq 'print') {
536 0         0 print "# NOT doing PARI-eval: print() seen\n";
537             } else {
538 1         10 print "# NOT doing PARI-eval: variable `$1' converted to Perl before was seen\n";
539             }
540 1 50       3 if (defined $userfun) {
541 0         0 $userfun .= "|$n";
542             } else {
543 1         3 $userfun = $n;
544             }
545 1         5 return;
546             }
547 3         25 print "# doing PARI-eval of a function `$n' instead\n";
548 3         63 PARI $IN;
549 20     20   161 no strict 'refs';
  20         33  
  20         1785  
550 3         17 *$n = Math::Pari::__wrap_PARI_macro $n;
551             }
552 719 100       1060 return if $RET;
553 680 100       1015 if ($in =~ /^\s*alias\s*\(\s*(\w+)\s*,\s*(\w+)\s*\)$/) {
554 1         32 print "# Aliasing `$1' ==> `$2'\nok $current_num\n";
555 20     20   108 no strict 'refs';
  20         33  
  20         74177  
556 1         3 *$1 = \&{$2};
  1         7  
557 1         6 return;
558             }
559 679 100       2762 if ($in !~ /\w\(/) { # No function calls
    100          
560             # XXXX Primitive!
561             # Constants: (.?) eats following + or - (2+3 ==> PARI(2)+PARI(3))
562 25         215 $in =~ s/(^|\G|\W)([-+]?)(\d+(\.\d*)?(?:e-?\d+)?)(.?)/$1 $2 PARI($3) $5/gi;
563             # Big integer constants:
564 25         72 $in =~ s/\bPARI\((\d{10,})\)/PARI('$1')/g;
565             } elsif ($in =~ /\b(elllseries|binomial|mathilbert|intnum|intfuncinit|intfuncinit)\b/) { # 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 32         170 $in =~ s/(^|\G|\W)([-+]?)(?!\d{0,6}\.5\b)(\d+\.\d*(?:e-?\d+)?)/$1 $2 PARI('$3') /gi;
570             # Bug in GP??? Too sensitive to precision of 4.5 in intfuncinit(t=[-oo, 4.5],[oo, 4.5], gamma(2+I*t)^3, 1);
571 32 100       95 $in =~ s/(^|\G|\W)([-+]?)(\d+\.\d*(?:e-?\d+)?)/$1 $2 PARI('$3') /gi
572             if $in =~ /intfuncinit/;
573             # Big integer constants:
574 32         57 $in =~ s/\bPARI\((\d{10,})\)/PARI('$1')/g;
575             } else {
576             # Substitute big integer constants
577 622         2915 $in =~ s/(^|\G|\W)(\d{10,}(?!\.\d*(?:e-?\d+)?))(.?)/$1 PARI('$2') $3/gi;
578             # Substitute division
579 622         1021 $in =~ s/(^|[\-\(,\[=+*\/])(\d+)\s*\/\s*(\d+)(?=$|[*+\-\/\),\]])/$1 PARI($2)\/PARI($3) /g;
580             }
581 679         721 my %seen_now;
582             # Substitute i= in loop commands
583 679 100       1733 if ($in !~ /\b(hermite|mathnf|until)\s*\(/) { # Special case, not loop-with-=
584 674         970 $in =~ s/([\(,])(\w+)=(?!=)/ $seen_now{$2} = '$'; "$1$2," /ge;
  72         226  
  72         262  
585             }
586             # Substitute print
587 679         813 $in =~ s/\b(|p|tex)print(tex|)\(/ 'my_' . $1 . $2 . 'print(1,' /ge;
  17         54  
588 679         746 $in =~ s/\b(|p|tex)print1\(/ 'my_' . $1 . 'print(0,'/ge;
  6         15  
589 679 50 33     1093 if ($skip_eval and $in =~ /\beval\(/g) { # eval($y)
590 0         0 print("# `$in'\nok $current_num # Skipping: eval's signature C is not supported yet\n"), return;
591             }
592 679         1094 $in =~ s/\b(eval|shift|sort)\(/&$1\(/g; # eval($y)
593             # Special case -oo (with $oo=[PARI(1)] done earlier;
594             # Having $oo defined without external PARI tests conversions; but it'sn't overloaded in older PARI
595 679 50 33     3114 $in =~ s/-oo\b/- PARI(\$oo)/ if $seen_now{oo} or Math::Pari::pari_version_exp < 2009000;
596             # Recognize variables and prepend $ in assignments
597             # s/\b(direuler\s*\(\s*\w+\s*),/$1=/; # direuler
598 679 100       1150 $in =~ s/\bX\b/PARIvar("X")/g if $in =~ /\bdireuler\b/;
599 679         3623 $in =~ s/(^\s*|[;(]\s*)(?=(\w+)\s*=\s*)/$seen_now{$2} = '$'; pre_update_seen($2); $1 . '$'/ge; # Assignment
  94         323  
  94         182  
  94         864  
600 679 50       1214 if ($in =~ /\.((?!\d|(?<=\d\.)e-?\d)\w+(?![\w"]))/) {
601 0         0 print("# `$in'\nok $current_num # Skipping: methods not supported yet (.$1)\n"), return;
602             }
603 679 50       977 if ($in =~ /(?
604 0         0 print("# `$in'\nok $current_num # Skipping: |var<- not supported yet\n"), return;
605             }
606             # Prepend $ to variables (not before '^' - inside of 'o(x^17)'):
607 679         3632 $in =~ s/(^|[^\$])\b([a-zA-Z]\w*)\b(?!\s*[\(^])/
608 996   100     5541 ($1 || '') . ($seen{$2} || $seen_now{$2} || '') . $2
      100        
609             /ge;
610             # Skip if did not substitute variables:
611 679         4674 while ($in =~ /(^|[^\$])\b([a-zA-Z]\w*)\b(?!\s*[\{\(^])/g) {
612             print("# `$in'\nok $current_num # Skipping: variable `$2' was not set\n"), return
613 78 100 66     620 unless $seen{$2} and $seen{$2} eq ' ' or $in =~ /\"/;
      100        
614             # Let us hope that lines which contain '"' do not contain unset vars
615             }
616             # Simplify for the following conversion:
617 677         901 $in =~ s/\brandom\(\)/random/g;
618             # Sub-ify sum,prod,intnum* sumnum etc, psploth, ploth etc
619 677         1667 my $oneArg = qr/(?: # 3 levels of parentheses supported
620             [^(,)\[\]]+
621             (?=
622             [(,)\[\]]
623             )
624             |
625             \( # One level of parenths
626             (?:
627             [^()]+
628             (?=
629             [()]
630             )
631             |
632             \( # Second level of parenths
633             (?:
634             [^()]+
635             (?=
636             [()]
637             )
638             | \( [^()]* \) # Third level of parens
639             )*
640             \) # Second level of parenths ends
641             )*
642             \)
643             |
644             \[ # One level of brackets
645             (?:
646             [^\[\]]+
647             (?=
648             [\[\]]
649             )
650             |
651             \[ [^\[\]]+ \] # Second level of brackets
652             )*
653             \]
654             )* # 3 levels of parenths supported
655             /x;
656 677         15387 1 while
657             $in =~ s/ (
658             \b
659             (?:
660             (?: # For these, sub{}ify the fourth argument
661             sum
662             |
663             intnum(?!init\b)\w*
664             |
665             intfuncinit
666             |
667             int\w*inv
668             |
669             intcirc\w*
670             |
671             sumnum(?!init\b)\w*
672             |
673             forprime
674             |
675             psploth
676             |
677             ploth
678             |
679             prod (?: euler )?
680             |
681             direuler
682             ) \s*
683             \( (?: $oneArg [=,] ){3} # $x,1,100
684             | (?: # For these, sub{}ify the third argument
685             sumalt
686             |
687             prodinf
688             ) \s*
689             \( (?: $oneArg [=,] ){2} # $x,1
690             | (?: # For these, sub{}ify the fifth argument
691             plothexport
692             ) \s*
693             \( (?: $oneArg [=,] ){4} # "ps",$x,100
694             | ( # 2: For these, sub{}ify the last argument
695             solve
696             |
697             (?:
698             post
699             )?
700             ploth (?! raw (?:export)? \b | sizes \b | export \b ) \w+
701             |
702             # sum \w*
703             sum (?! alt | num (?:init)? \b) \w+
704             |
705             v? vector v?
706             |
707             matrix
708             |
709             intgen
710             |
711             intopen
712             |
713             for \w*
714             ) \s*
715             \( (?: $oneArg , )* # "ps",$x,1,100; do not accept "=" after the iterator variable
716             )
717             ) # end group 1
718             (?!\s*sub(?:\s*\(\$*\))?\s*\{) # Skip already converted...
719             ( $oneArg ) # 3: This follows after a comma on toplevel
720             (?(2) (?= \) ) | (?= [),] ) )
721 121         496 /subify_iterators("$1","$3")/xge;
722             # Convert 10*20 to integer
723 677         1744 $in =~ s/(\d+)(?=\*\*\d)/ PARI($1) /g;
724             # Convert blah[3], blah()[3] to blah->[-1+3]
725 677         901 $in =~ s/([\w\)])\[/$1 -> [-1+/g;
726             # Fix [,3] converted to [-1+,3]
727 677         746 $in =~ s/\[-1\+,/\[-1+/g;
728             # Fix [2,3] converted to [-1+2,3]
729 677         755 $in =~ s/\[(-1\+[^,\[\]\(\)]+),([^\(\)\[\]]+)\]/\[-1+$2\]\[$1\]/g;
730             # Workaround for &eval test:
731 677         663 $in =~ s/\$y=\$x;&eval\b(.*)/PARI('y=x');&eval$1;\$y=\$x/;
732 677         662 $in =~ s/\$yy=\$xx;&eval\b(.*)/PARI('yy=xx');&eval$1;\$yy=\$xx/;
733             # Workaround for hardly-useful support for &:
734 677 100       1005 if ($in =~ s/([,\(]\s*)&(\$(\w+)\s*)(?=[,\)])/$1$2/) {
735             #$in = qq(\$$3 = PARI "'$3"; \$OUT = do { $in }; \$$3 = PARI "$3"; \$OUT)
736             }
737             # Workaround for kill:
738 677         631 $in =~ s/^kill\(\$(\w+)\);/kill('$1');\$$1=PARIvar '$1';/;
739             # Workaround for plothsizes:
740 677         662 $in =~ s/\bplothsizes\(/safe_sizes(/;
741             # XXXX Silly workaround for `my' (probably a side effect of replacing "var=" by "var," in iterators???)
742 677         1811 $in =~ s/(?<=\bmy\(\$)(\w+),(?=\w+\()/$1)=(/g;
743 677 100       22044 print "# eval", ($noans ? "-$noans" : '') ,": $in\n";
744 677         1953 $printout = '';
745 677   100     6730 my $have_floats = ($in =~ /\d+\.\d*|\d{10,}/
746             or $in =~ /\b( ellinit|zeta|bin|comprealraw|frac|
747             lseriesell|powrealraw|legendre|suminf|
748             forstep )\b/x);
749 677         705 my $newvars;
750 677   66     1993 $ourvars{$1}++ or $newvars++ while $in =~ /(?
751 677 100       960 if ($newvars) {
752 75         633 $ourvars_rx = join '|', sort keys %ourvars;
753 75         2916 $ourvars_rx = qr($ourvars_rx);
754             }
755             # Remove the value from texprint:
756             # pop @$out if $in =~ /texprint/ and @$out == 2;
757 677         993 my $pre_time = time() - $ini_time;
758 677         41556 $res = eval "$in";
759 677         3527 my $run_time = time() - $ini_time - $pre_time;
760 677         1145 $rres = $res;
761 677 100 100     579515 $rres = pari_print $res if defined $res and ref $res;
762 677         958 my $re_out;
763 677 100       1060 if ($doprint) {
764 14 50       30 if ($in =~ /my_texprint/) { # Special-case, assume one wrapped with \n
765 0         0 $rout = join "", @$out, "\t";
766             } else {
767 14         32 $rout = join "\t", @$out, "";
768             }
769 14 100       54 if ($have_floats) {
770 1         2 $printout = massage_floats $printout, "14f";
771 1         1 $rout = massage_floats $rout, "14f";
772             }
773             # New wrapping code gets in the way:
774 14         91 $printout =~ s/\s+/ /g;
775 14         23 $rout =~ s/\t,/,/g;
776 14         73 $rout =~ s/\s+/ /g;
777              
778 14         26 $rout =~ s/,\s*/, /g;
779 14         18 $printout =~ s/,\s*/, /g;
780 14         69 $rout =~ s/\s*([-+])\s*/ $1 /g;
781 14         55 $printout =~ s/\s*([-+])\s*/ $1 /g;
782             } else {
783             # Special-case several tests in all.t
784 663 100 100     3197 if (($have_floats or $in =~ /^(sinh?|solve)\b/) and ref $res) {
      100        
785             # do it the hard way: we cannot massage floats before doing wrapping
786 79         230 $rout = mformat @$out;
787 79 50 33     433 if (defined $rres and $rres !~ /\n/) {
788 79         179 $rout =~ s/\]\s*\[/; /g;
789 79         173 $rout =~ s/\[\s+/[/g;
790 79         113 $rout =~ s/,\n/, \n/g; # Spaces were removed
791 79         227 $rout =~ s/\n//g; # Long wrapped text
792             }
793 79 100 100     383 if ($rout =~ /\[.*[-+,;]\s/ or $rout =~ /\bQfb\b/) {
794 24         996 $rout =~ s/,*\s+/ /g;
795 24 50       797 $rres =~ s/,*\s+/ /g if defined $res;
796 24 50       137 $rres =~ s/,/ /g if defined $res; # in 2.2.10 ", "
797 24         67 $rout =~ s/;\s*/; /g; # in 2.2.10 "; "
798 24 50       80 $rres =~ s/;\s*/; /g if defined $res; # in 2.2.10 "; "
799             }
800 79 100       410 if ($in =~ /\b(zeta|bin|comprealraw|frac|lseriesell|powrealraw|pollegendre|legendre|suminf|ellinit)\b/) {
801 17         111 $rres = massage_floats $rres, "14f";
802 17         39 $rout = massage_floats $rout, "14f";
803             } else {
804 62         153 $rres = massage_floats $rres;
805 62         117 $rout = massage_floats $rout;
806             }
807 79         406 $rout =~ s/\s*([-+])\s*/$1/g;
808 79 50       2488 $rres =~ s/\s*([-+])\s*/$1/g if defined $res;
809             } else {
810 584         1244 $re_out = re_format @$out;
811             # $rout = mformat @$out;
812             # if (defined $rres and $rres !~ /\n/) {
813             # $rout =~ s/\]\s*\[/; /g;
814             # $rout =~ s/,\n/, \n/g; # Spaces were removed
815             # $rout =~ s/\n//g; # Long wrapped text
816             # }
817             # if ($rout =~ /\[.*[-+,;]\s/) {
818             # $rout =~ s/,*\s+/ /g;
819             # $rres =~ s/,*\s+/ /g if defined $res;
820             # }
821             # $rout =~ s/\s*([-+])\s*/$1/g;
822             # $rres =~ s/\s*([-+])\s*/$1/g if defined $res;
823             }
824             }
825              
826 677 100       1171 if ($@) {
827 8 50 33     51 if ($@ =~ /^Undefined subroutine &main::(\w+)/
    50 33        
    50 33        
    50          
828             and $not_yet_defined{$1}) {
829 0         0 print "# in='$in'\nok $current_num # Skipped: `$1' is known to be undefined\n";
830             } elsif ($@ =~ /high resolution graphics disabled/
831             and 0 >= Math::Pari::have_graphics()) {
832 0         0 print "# in='$in'\nok $current_num # Skipped: graphic is disabled in this build\n";
833             } elsif ($@ =~ /pari_daemon without waitpid & setsid is not yet implemented/) {
834 0         0 print "# in='$in'\nok $current_num # Skipped: graphic (pari_daemon) is disabled in this build\n";
835             } elsif ($@ =~ /gnuplot-like plotting environment not loaded yet/
836             and $skip_gnuplot) {
837 8         245 print "# in='$in'\nok $current_num # Skipped: Term::Gnuplot is not loaded\n";
838             } else { # XXXX Parens needed???
839 0         0 nok_print( $current_num, $in, "not ok $current_num # in='$in', err='$@'\n" );
840             }
841 8         69 return;
842             }
843 669         687 my $cmp;
844 669 100 100     1677 if (defined $rres and defined $re_out) {
845 547         811 for my $how (0,'Mat') {
846 578         610 my $RR = $rres;
847 578 100       2650 $RR =~ s/\bMat\(($matched_par)\)/[$1]/g if $how;
848 578         625 $cmp = eval { $RR =~ /^$re_out$/ };
  578         19571  
849 578 50 33     1318 if ($@ and $@ =~ /regexp too big/) {
850 0         0 print "ok $current_num # Skipped: $@\n";
851 0         0 update_seen \%seen_now;
852 0         0 $prev = $res;
853 0         0 return;
854             }
855 578 100       1069 last if $cmp
856             }
857             }
858 669         951 my $post_time = time() - $ini_time - $pre_time - $run_time;
859 669 50 100     4258 if (not $noans and defined $re_out
    100 33        
    50 66        
    50 100        
      33        
      66        
      66        
860             and (not defined $rres or not $cmp)) {
861 0         0 $out->[0] =~ s/\n/\t/g; # @$out usually has 1 elt
862 0         0 nok_print $current_num, $in, "not ok $current_num # in='$in'\n# out='", $rres, "', type='", ref $res,
863             "'\n# pari==='", join("\t", @$out), "'\n# re_out='$re_out'\n";
864             } elsif (not $noans and defined $re_out) {
865 516         19103 print "ok $current_num # run_time=$run_time, post_time=$post_time, pre_time=$pre_time\n";
866 516         2056 update_seen \%seen_now;
867 516         4903 $prev = $res;
868             } elsif (not $noans and (not defined $rres or filter_res $rres ne filter_res $rout)) {
869 0         0 nok_print $current_num, $in, "not ok $current_num # in='$in'\n# out='", $rres, "', type='", ref $res,
870             "'\n# expect='$rout'\n";
871             } elsif ($doprint and $printout ne $rout) {
872 0         0 nok_print $current_num, $in, "not ok $current_num # in='$in'\n# printout='", $printout,
873             "'\n# expect='$rout', type='", ref $res,"'\n";
874             } else {
875 153         7095 print "ok $current_num # run_time=$run_time, post_time=$post_time, pre_time=$pre_time\n";
876 153         705 update_seen \%seen_now;
877 153         1960 $prev = $res;
878             }
879             }
880             }
881              
882             sub process_error {
883 3     4   10 my ($in, $out, $error) = @_;
884 3         5 $current_num++;
885 3         31 print("# `$in'\nok $current_num # Skipping: test producing PARI error unsupported yet (err=$error)\n");
886             }
887              
888             sub process_definition {
889 0     0   0 my ($name, $def) = @_;
890 0         0 $current_num++;
891 0         0 eval "PARI('$def'); import Math::Pari $name;";
892 0 0       0 if ($@) {
893 0         0 chomp $@;
894 0         0 print("not ok $current_num # definition: `$def' error `$@'\n");
895             } else {
896 0         0 print("# definition $current_num: `$def'\nok $current_num\n");
897             }
898             }
899              
900             sub process_set {
901 0     0   0 my ($in, $out) = @_;
902 0 0       0 return process_test("setprecision($1)", 'noans', []) if $in =~ /^\\p\s*(\d+)$/;
903 0         0 $current_num++;
904 0         0 print("# `$in'\nok $current_num # Skipping setting test\n");
905             }
906              
907             sub process_print {
908 2     2   8 my ($in, @out) = @_;
909 2         2 $current_num++;
910 2         62 print("# $current_num: `$in'\nok $current_num # Skipping plot() - can't test it yet\n");
911             }
912              
913             sub process_multi {
914 0     0   0 my ($in, $out) = @_;
915 0         0 my @out = @$out;
916 0         0 $current_num++;
917 0         0 print("# `$in'\nok $current_num # Skipping multiline\n");
918             }
919              
920             sub my_print {
921 126     126   136 my $nl = CORE::shift;
922 126 100       144 @_ = map {(ref) ? (pari_print $_) : $_} @_;
  231         657  
923 126         196 $printout .= join '', @_;
924 126 100       183 $printout .= "\t" if $nl;
925 126         1423 return;
926             }
927              
928             sub my_pprint {
929 0     0   0 my $nl = CORE::shift;
930 0 0       0 @_ = map {(ref) ? (pari_pprint $_) : $_} @_;
  0         0  
931 0         0 $printout .= join '', @_;
932 0 0       0 $printout .= "\t" if $nl;
933 0         0 return;
934             }
935              
936             sub my_texprint {
937 0     0   0 my $nl = CORE::shift;
938 0 0       0 @_ = map {(ref) ? (pari_texprint $_) : $_} @_;
  0         0  
939 0         0 $printout .= join '', @_;
940 0 0       0 $printout .= "\t" if $nl;
941 0         0 return;
942             }
943              
944             sub prec {
945 15     15   85 setprecision($_[0]);
946 15         251 print "# Setting precision to $_[0] digits.\n";
947 15 50       330 print "ok $current_num\n" unless $_[1];
948             }
949             sub bprec {
950 0     0   0 PARI("default(realbitprecision,$_[0])"); # setbitprecision($_[0]);
951 0         0 print "# Setting bitprecision to $_[0] bits.\n";
952 0         0 print "# bitprecision: res=", PARI("default(realbitprecision)"),"\n";
953 0 0       0 print "ok $current_num\n" unless $_[1];
954             }
955             sub sprec {
956 1     1   4 setseriesprecision($_[0]);
957 1         8 print "# Setting series precision to $_[0] digits.\n";
958 1         10 print "ok $current_num\n";
959             }
960              
961             # *Need* to convert to PARI, otherwise the arithmetic will propagate
962             # the values to floats
963              
964 1 50   1   1 sub safe_sizes { eval {plothsizes()} or PARI [1000,1000,20,20,20,20]}
  1         120