[svn:parrot] r38377 - in trunk: config/auto t/steps

jkeenan at svn.parrot.org jkeenan at svn.parrot.org
Mon Apr 27 01:37:14 UTC 2009


Author: jkeenan
Date: Mon Apr 27 01:37:12 2009
New Revision: 38377
URL: https://trac.parrot.org/parrot/changeset/38377

Log:
Add tests for _set_intvalmaxmin() and _set_floatvalmaxmin().

Modified:
   trunk/config/auto/sizes.pm
   trunk/t/steps/auto_sizes-01.t

Modified: trunk/config/auto/sizes.pm
==============================================================================
--- trunk/config/auto/sizes.pm	Sun Apr 26 15:18:51 2009	(r38376)
+++ trunk/config/auto/sizes.pm	Mon Apr 27 01:37:12 2009	(r38377)
@@ -245,7 +245,7 @@
         $ivmax = 'LLONG_MAX';
     }
     else {
-        die qq{Configure.pl:  Can't find limits for type '$iv'\n};
+        die qq{Configure.pl:  Cannot find limits for type '$iv'\n};
     }
 
     $conf->data->set( intvalmin   => $ivmin );
@@ -270,7 +270,7 @@
         $nvmax = 'LDBL_MAX';
     }
     else {
-        die qq{Configure.pl:  Can't find limits for type '$nv'\n};
+        die qq{Configure.pl:  Cannot find limits for type '$nv'\n};
     }
 
     $conf->data->set( floatvalmin => $nvmin );

Modified: trunk/t/steps/auto_sizes-01.t
==============================================================================
--- trunk/t/steps/auto_sizes-01.t	Sun Apr 26 15:18:51 2009	(r38376)
+++ trunk/t/steps/auto_sizes-01.t	Mon Apr 27 01:37:12 2009	(r38377)
@@ -5,7 +5,7 @@
 
 use strict;
 use warnings;
-use Test::More qw(no_plan); # tests => 42;
+use Test::More tests => 58;
 use Carp;
 use lib qw( lib t/configure/testlib );
 use_ok('config::init::defaults');
@@ -282,6 +282,87 @@
 is( $conf->data->get( 'hugefloatvalsize' ), $conf->data->get('doublesize'),
     "Got expected size for hugefloatvalsize");
 
+########## _set_intvalmaxmin() ##########
+
+my @trueintvals = (
+    $conf->data->get( 'iv' ),
+    $conf->data->get( 'intvalmin' ),
+    $conf->data->get( 'intvalmax' ),
+);
+$conf->data->set( iv => 'int' );
+auto::sizes::_set_intvalmaxmin( $conf );
+is( $conf->data->get( 'intvalmin' ), 'INT_MIN',
+    "Got expected value for 'intvalmin' when 'iv' is 'int'" );
+is( $conf->data->get( 'intvalmax' ), 'INT_MAX',
+    "Got expected value for 'intvalmax' when 'iv' is 'int'" );
+
+$conf->data->set( iv => 'long' );
+auto::sizes::_set_intvalmaxmin( $conf );
+is( $conf->data->get( 'intvalmin' ), 'LONG_MIN',
+    "Got expected value for 'intvalmin' when 'iv' is 'long'" );
+is( $conf->data->get( 'intvalmax' ), 'LONG_MAX',
+    "Got expected value for 'intvalmax' when 'iv' is 'long'" );
+
+$conf->data->set( iv => 'long int' );
+auto::sizes::_set_intvalmaxmin( $conf );
+is( $conf->data->get( 'intvalmin' ), 'LONG_MIN',
+    "Got expected value for 'intvalmin' when 'iv' is 'long int'" );
+is( $conf->data->get( 'intvalmax' ), 'LONG_MAX',
+    "Got expected value for 'intvalmax' when 'iv' is 'long int'" );
+
+$conf->data->set( iv => 'long long' );
+auto::sizes::_set_intvalmaxmin( $conf );
+is( $conf->data->get( 'intvalmin' ), 'LLONG_MIN',
+    "Got expected value for 'intvalmin' when 'iv' is 'long long'" );
+is( $conf->data->get( 'intvalmax' ), 'LLONG_MAX',
+    "Got expected value for 'intvalmax' when 'iv' is 'long long'" );
+
+$conf->data->set( iv => 'long long int' );
+auto::sizes::_set_intvalmaxmin( $conf );
+is( $conf->data->get( 'intvalmin' ), 'LLONG_MIN',
+    "Got expected value for 'intvalmin' when 'iv' is 'long long int'" );
+is( $conf->data->get( 'intvalmax' ), 'LLONG_MAX',
+    "Got expected value for 'intvalmax' when 'iv' is 'long long int'" );
+
+my $badtype = 'foobar';
+$conf->data->set( iv => $badtype );
+eval { auto::sizes::_set_intvalmaxmin( $conf ); };
+like($@, qr/Configure.pl:  Cannot find limits for type '$badtype'/,
+    "Got expected 'die' message for unrecognized 'iv'");
+
+# Reset true values prior to subsequent tests.
+$conf->data->set( 'iv' => $trueintvals[0] );
+$conf->data->set( 'intvalmin' => $trueintvals[1] );
+$conf->data->set( 'intvalmax' => $trueintvals[2] );
+
+########## _set_floatvalmaxmin() ##########
+
+my @truefloatvals = (
+    $conf->data->get( 'nv' ),
+    $conf->data->get( 'floatvalmin' ),
+    $conf->data->get( 'floatvalmax' ),
+);
+
+$conf->data->set( nv => 'double' );
+auto::sizes::_set_floatvalmaxmin( $conf );
+is( $conf->data->get( 'floatvalmin' ), 'DBL_MIN',
+    "Got expected value for 'floatvalmin' when 'nv' is 'double'" );
+is( $conf->data->get( 'floatvalmax' ), 'DBL_MAX',
+    "Got expected value for 'floatvalmax' when 'nv' is 'double'" );
+
+$conf->data->set( nv => 'long double' );
+auto::sizes::_set_floatvalmaxmin( $conf );
+is( $conf->data->get( 'floatvalmin' ), 'LDBL_MIN',
+    "Got expected value for 'floatvalmin' when 'nv' is 'long double'" );
+is( $conf->data->get( 'floatvalmax' ), 'LDBL_MAX',
+    "Got expected value for 'floatvalmax' when 'nv' is 'long double'" );
+
+$badtype = 'foobar';
+$conf->data->set( nv => $badtype );
+eval { auto::sizes::_set_floatvalmaxmin( $conf ); };
+like($@, qr/Configure.pl:  Cannot find limits for type '$badtype'/,
+    "Got expected 'die' message for unrecognized 'nv'");
+
 pass("Completed all tests in $0");
 
 ################### DOCUMENTATION ###################


More information about the parrot-commits mailing list