Author: jkeenan
Date: Sun Jan  6 18:42:50 2008
New Revision: 24633

Modified:
   trunk/config/auto/gmp.pm
   trunk/t/configure/143-auto_gmp-03.t

Log:
Refactor more guts of runstep() into _recheck_settings().  Write tests for this 
sub in t/configure/143-auto_gmp-03.t.  Add description of GMP taken from GNU 
documentation.

Modified: trunk/config/auto/gmp.pm
==============================================================================
--- trunk/config/auto/gmp.pm    (original)
+++ trunk/config/auto/gmp.pm    Sun Jan  6 18:42:50 2008
@@ -9,6 +9,15 @@
 
 Determines whether the platform supports GMP.
 
+From L<http://gmplib.org/>:  "GMP is a free library for arbitrary precision
+arithmetic, operating on signed integers, rational numbers, and floating point
+numbers. There is no practical limit to the precision except the ones implied
+by the available memory in the machine GMP runs on. ..."
+
+"The main target applications for GMP are cryptography applications and
+research, Internet security applications, algebra systems, computational
+algebra research, etc."
+
 =cut
 
 package auto::gmp;
@@ -66,26 +75,11 @@
     my $has_gmp = 0;
     if ( !$@ ) {
         my $test = $conf->cc_run();
-#        if ( $test eq $self->{cc_run_expected}) {
-#            $has_gmp = 1;
-#            print " (yes) " if $verbose;
-#            $self->set_result('yes');
-#
-#            $conf->data->set(
-#                gmp     => 'define',
-#                HAS_GMP => $has_gmp,
-#            );
-#        }
         $has_gmp = $self->_evaluate_cc_run( $conf, $test, $has_gmp, $verbose );
     }
     unless ($has_gmp) {
-
-        # The Config::Data settings might have changed for the test
-        $conf->data->set( 'libs',      $libs );
-        $conf->data->set( 'ccflags',   $ccflags );
-        $conf->data->set( 'linkflags', $linkflags );
-        print " (no) " if $verbose;
-        $self->set_result('no');
+        # The Parrot::Configure settings might have changed while class ran
+        $self->_recheck_settings($conf, $libs, $ccflags, $linkflags, $verbose);
     }
 
     return 1;
@@ -136,6 +130,15 @@
     return $has_gmp;
 }
 
+sub _recheck_settings {
+    my ($self, $conf, $libs, $ccflags, $linkflags, $verbose) = @_;
+    $conf->data->set( 'libs',      $libs );
+    $conf->data->set( 'ccflags',   $ccflags );
+    $conf->data->set( 'linkflags', $linkflags );
+    print " (no) " if $verbose;
+    $self->set_result('no');
+}
+
 1;
 
 # Local Variables:

Modified: trunk/t/configure/143-auto_gmp-03.t
==============================================================================
--- trunk/t/configure/143-auto_gmp-03.t (original)
+++ trunk/t/configure/143-auto_gmp-03.t Sun Jan  6 18:42:50 2008
@@ -5,7 +5,7 @@
 
 use strict;
 use warnings;
-use Test::More tests => 19;
+use Test::More tests => 28;
 use Carp;
 use Cwd;
 use File::Temp qw( tempdir );
@@ -83,6 +83,42 @@
     $step->set_result(undef); 
 }
 
+my ($libs, $ccflags, $linkflags);
+
+$libs = q{-lalpha};
+$ccflags = q{-Ibeta};
+$linkflags = q{-Lgamma};
+$verbose = undef;
+$step->_recheck_settings($conf, $libs, $ccflags, $linkflags, $verbose);
+like($conf->data->get('libs'), qr/$libs/,
+    "Got expected value for 'libs'");
+like($conf->data->get('ccflags'), qr/$ccflags/,
+    "Got expected value for 'ccflags'");
+like($conf->data->get('linkflags'), qr/$linkflags/,
+    "Got expected value for 'linkflags'");
+is($step->result, 'no', "Expected result was set");
+
+{
+    my $stdout;
+    $libs = q{-lalpha};
+    $ccflags = q{-Ibeta};
+    $linkflags = q{-Lgamma};
+    $verbose = 1;
+    capture(
+        sub { $step->_recheck_settings(
+            $conf, $libs, $ccflags, $linkflags, $verbose); },
+        \$stdout,
+    );
+    like($conf->data->get('libs'), qr/$libs/,
+        "Got expected value for 'libs'");
+    like($conf->data->get('ccflags'), qr/$ccflags/,
+        "Got expected value for 'ccflags'");
+    like($conf->data->get('linkflags'), qr/$linkflags/,
+        "Got expected value for 'linkflags'");
+    is($step->result, 'no', "Expected result was set");
+    like($stdout, qr/\(no\)/, "Got expected verbose output");
+}
+
 pass("Completed all tests in $0");
 
 ################### DOCUMENTATION ###################

Reply via email to