Change 28503 by [EMAIL PROTECTED] on 2006/07/07 18:38:01

        Subject: [PATCH] Test scripts for I18N::Langinfo and POSIX
        From: Sébastien Aperghis-Tramoni <[EMAIL PROTECTED]>
        Date: Fri, 07 Jul 2006 11:02:31 +0200
        Message-ID: <[EMAIL PROTECTED]>
        
        Only includes changes to:
        * ext/I18N/Langinfo/t/Langinfo.t
        * ext/POSIX/t/sysconf.t
        * ext/POSIX/t/termios.t

Affected files ...

... //depot/perl/MANIFEST#1426 edit
... //depot/perl/ext/I18N/Langinfo/t/Langinfo.t#2 edit
... //depot/perl/ext/POSIX/t/sysconf.t#1 add
... //depot/perl/ext/POSIX/t/termios.t#1 add

Differences ...

==== //depot/perl/MANIFEST#1426 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#1425~28501~   2006-07-07 07:12:59.000000000 -0700
+++ perl/MANIFEST       2006-07-07 11:38:01.000000000 -0700
@@ -1008,7 +1008,9 @@
 ext/POSIX/t/math.t             Basic math tests for POSIX
 ext/POSIX/t/posix.t            See if POSIX works
 ext/POSIX/t/sigaction.t                See if POSIX::sigaction works
+ext/POSIX/t/sysconf.t          See if POSIX works
 ext/POSIX/t/taint.t            See if POSIX works with taint
+ext/POSIX/t/termios.t          See if POSIX works
 ext/POSIX/t/time.t             See if POSIX time-related functions work
 ext/POSIX/t/waitpid.t          See if waitpid works
 ext/POSIX/typemap              POSIX extension interface types

==== //depot/perl/ext/I18N/Langinfo/t/Langinfo.t#2 (text) ====
Index: perl/ext/I18N/Langinfo/t/Langinfo.t
--- perl/ext/I18N/Langinfo/t/Langinfo.t#1~20269~        2003-07-28 
08:07:22.000000000 -0700
+++ perl/ext/I18N/Langinfo/t/Langinfo.t 2006-07-07 11:38:01.000000000 -0700
@@ -1,24 +1,35 @@
-#!./perl
+#!perl -T
 
 BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
-    require Config; import Config;
-    if ($Config{'extensions'} !~ m!\bI18N/Langinfo\b! ||
-       $Config{'extensions'} !~ m!\bPOSIX\b!)
-    {
-       print "1..0 # skip: I18N::Langinfo or POSIX unavailable\n";
-       exit 0;
+    if ($ENV{PERL_CORE}) {
+        chdir 't';
+        @INC = '../lib';
     }
 }
-    
-use I18N::Langinfo qw(langinfo);
-use POSIX qw(setlocale LC_ALL);
 
-setlocale(LC_ALL, $ENV{LC_ALL} = $ENV{LANG} = "C");
+use strict;
+use Config;
+use Test::More;
+
+plan skip_all => "I18N::Langinfo or POSIX unavailable" 
+    if $Config{'extensions'} !~ m!\bI18N/Langinfo\b!;
+
+my @constants = qw(ABDAY_1 DAY_1 ABMON_1 MON_1 RADIXCHAR AM_STR THOUSEP 
D_T_FMT D_FMT T_FMT);
+
+plan tests => 1 + 3 * @constants;
+
+use_ok('I18N::Langinfo', 'langinfo', @constants);
+
+for my $constant (@constants) {
+    SKIP: {
+        my $string = eval { langinfo(eval "$constant()") };
+        is( $@, '', "calling langinfo() with $constant" );
+        skip "returned string was empty, skipping next two tests", 2 unless 
$string;
+        ok( defined $string, "checking if the returned string is defined" );
+        cmp_ok( length($string), '>=', 1, "checking if the returned string has 
a positive length" );
+    }
+}
 
-print "1..1\n"; # We loaded okay.  That's about all we can hope for.
-print "ok 1\n";
 exit(0);
 
 # Background: the langinfo() (in C known as nl_langinfo()) interface

==== //depot/perl/ext/POSIX/t/sysconf.t#1 (text) ====
Index: perl/ext/POSIX/t/sysconf.t
--- /dev/null   2006-05-22 12:45:36.372675500 -0700
+++ perl/ext/POSIX/t/sysconf.t  2006-07-07 11:38:01.000000000 -0700
@@ -0,0 +1,62 @@
+#!perl -T
+
+BEGIN {
+    if ($ENV{PERL_CORE}) {
+        chdir 't';
+        @INC = '../lib';
+    }
+
+    use Config;
+    use Test::More;
+    plan skip_all => "POSIX is unavailable" if $Config{'extensions'} !~ 
m!\bPOSIX\b!;
+}
+
+use strict;
+use File::Spec;
+use POSIX;
+use Scalar::Util qw(looks_like_number);
+
+my @path_consts = qw(
+    _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON _PC_MAX_INPUT
+    _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX _PC_PIPE_BUF _PC_VDISABLE
+);
+
+my @sys_consts = qw(
+    _SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL
+    _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_PAGESIZE _SC_SAVED_IDS
+    _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
+);
+
+plan tests => 2 * 3 * @path_consts + 3 * @sys_consts;
+
+my $r;
+
+# testing fpathconf()
+SKIP: {
+    my $fd = POSIX::open(File::Spec->curdir, O_RDONLY)
+        or skip "can't open current directory", 3 * @path_consts;
+
+    for my $constant (@path_consts) {
+        $r = eval { pathconf( File::Spec->curdir, eval "$constant()" ) };
+        is( $@, '', "calling pathconf($constant)" );
+        ok( defined $r, "\tchecking that the returned value is defined: $r" );
+        ok( looks_like_number($r), "\tchecking that the returned value looks 
like a number" );
+    }
+}
+
+# testing pathconf()
+for my $constant (@path_consts) {
+    $r = eval { pathconf( File::Spec->rootdir, eval "$constant()" ) };
+    is( $@, '', "calling pathconf($constant)" );
+    ok( defined $r, "\tchecking that the returned value is defined: $r" );
+    ok( looks_like_number($r), "\tchecking that the returned value looks like 
a number" );
+}
+
+# testing sysconf()
+for my $constant (@sys_consts) {
+    $r = eval { sysconf( eval "$constant()" ) };
+    is( $@, '', "calling sysconf($constant)" );
+    ok( defined $r, "\tchecking that the returned value is defined: $r" );
+    ok( looks_like_number($r), "\tchecking that the returned value looks like 
a number" );
+}
+

==== //depot/perl/ext/POSIX/t/termios.t#1 (text) ====
Index: perl/ext/POSIX/t/termios.t
--- /dev/null   2006-05-22 12:45:36.372675500 -0700
+++ perl/ext/POSIX/t/termios.t  2006-07-07 11:38:01.000000000 -0700
@@ -0,0 +1,49 @@
+#!perl -T
+
+BEGIN {
+    if ($ENV{PERL_CORE}) {
+        chdir 't';
+        @INC = '../lib';
+    }
+
+    use Config;
+    use Test::More;
+    plan skip_all => "POSIX is unavailable" if $Config{'extensions'} !~ 
m!\bPOSIX\b!;
+}
+
+use strict;
+use POSIX;
+
+my @getters = qw(getcflag getiflag getispeed getlflag getoflag getospeed);
+
+plan tests => 3 + 2 * (3 + NCCS() + @getters);
+
+my $r;
+
+# create a new object
+my $termios = eval { POSIX::Termios->new };
+is( $@, '', "calling POSIX::Termios->new" );
+ok( defined $termios, "\tchecking if the object is defined" );
+isa_ok( $termios, "POSIX::Termios", "\tchecking the type of the object" );
+
+# testing getattr()
+for my $i (0..2) {
+    $r = eval { $termios->getattr($i) };
+    is( $@, '', "calling getattr($i)" );
+    ok( defined $r, "\tchecking if the returned value is defined: $r" );
+}
+
+# testing getcc()
+for my $i (0..NCCS()-1) {
+    $r = eval { $termios->getcc($i) };
+    is( $@, '', "calling getcc($i)" );
+    ok( defined $r, "\tchecking if the returned value is defined: $r" );
+}
+
+# testing getcflag()
+for my $method (@getters) {
+    $r = eval { $termios->$method() };
+    is( $@, '', "calling $method()" );
+    ok( defined $r, "\tchecking if the returned value is defined: $r" );
+}
+
End of Patch.

Reply via email to