]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blobdiff - t/31-threads-teardown.t
Replace $] by "$]"
[perl/modules/Lexical-Types.git] / t / 31-threads-teardown.t
index 632293b6373a5057c3e609da3e8e51a720686a62..34e61acd2a75543af35eed20019f57a7c78a932c 100644 (file)
@@ -3,14 +3,20 @@
 use strict;
 use warnings;
 
-use Config qw/%Config/;
+sub skipall {
+ my ($msg) = @_;
+ require Test::More;
+ Test::More::plan(skip_all => $msg);
+}
+
+use Config qw<%Config>;
 
 BEGIN {
- if (!$Config{useithreads}) {
-  require Test::More;
-  Test::More->import;
-  plan(skip_all => 'This perl wasn\'t built to support threads');
- }
+ my $force = $ENV{PERL_LEXICAL_TYPES_TEST_THREADS} ? 1 : !1;
+ skipall 'This perl wasn\'t built to support threads'
+                                                    unless $Config{useithreads};
+ skipall 'perl 5.13.4 required to test thread safety'
+                                              unless $force or "$]" >= 5.013004;
 }
 
 use threads;
@@ -19,24 +25,25 @@ use Test::More;
 
 BEGIN {
  require Lexical::Types;
- if (Lexical::Types::LT_THREADSAFE()) {
-  plan tests => 1;
-  defined and diag "Using threads $_" for $threads::VERSION;
- } else {
-  plan skip_all => 'This Lexical::Types isn\'t thread safe';
- }
+ skipall 'This Lexical::Types isn\'t thread safe'
+                                         unless Lexical::Types::LT_THREADSAFE();
+ plan tests => 1;
+ defined and diag "Using threads $_" for $threads::VERSION;
 }
 
 sub run_perl {
  my $code = shift;
 
+ my $SystemRoot   = $ENV{SystemRoot};
  local %ENV;
+ $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot;
+
  system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code;
 }
 
 SKIP:
 {
- skip 'Fails on 5.8.2 and lower' => 1 if $] <= 5.008002;
+ skip 'Fails on 5.8.2 and lower' => 1 if "$]" <= 5.008002;
 
  my $status = run_perl <<' RUN';
   { package IntX; package IntY; package IntZ; }
@@ -48,11 +55,11 @@ SKIP:
   }
   use threads;
   $code = threads->create(sub {
-   $code = @expected = qw/IntX/;
+   $code = @expected = qw<IntX>;
    eval q{use Lexical::Types as => \&cb; my IntX $x;}; die if $@;
    return $code;
   })->join;
-  $code += @expected = qw/IntZ/;
+  $code += @expected = qw<IntZ>;
   eval q{my IntY $y;}; die if $@;
   eval q{use Lexical::Types as => \&cb; my IntZ $z;}; die if $@;
   $code += 256 if $code < 0;