aelemfast optimization opclass problem (c.f. [perl #38279])
[p5sagit/p5-mst-13.2.git] / ext / B / t / b.t
index 0d2e8bc..4337109 100755 (executable)
@@ -1,12 +1,16 @@
 #!./perl
 
 BEGIN {
-    chdir 't' if -d 't';
-    if ($^O eq 'MacOS') {
-       @INC = qw(: ::lib ::macos:lib);
+    if ($ENV{PERL_CORE}){
+       chdir('t') if -d 't';
+       if ($^O eq 'MacOS') {
+           @INC = qw(: ::lib ::macos:lib);
+       } else {
+           @INC = '.';
+           push @INC, '../lib';
+       }
     } else {
-       @INC = '.';
-       push @INC, '../lib';
+       unshift @INC, 't';
     }
     require Config;
     if (($Config::Config{'extensions'} !~ /\bB\b/) ){
@@ -18,7 +22,7 @@ BEGIN {
 $|  = 1;
 use warnings;
 use strict;
-use Test::More tests => 41;
+use Test::More tests => 53;
 
 BEGIN { use_ok( 'B' ); }
 
@@ -143,3 +147,19 @@ ok(! $gv_ref->is_empty(), "Test is_empty()");
 is($gv_ref->NAME(), "gv", "Test NAME()");
 is($gv_ref->SAFENAME(), "gv", "Test SAFENAME()");
 like($gv_ref->FILE(), qr/b\.t$/, "Testing FILE()");
+
+# The following return B::SPECIALs.
+is(ref B::sv_yes(), "B::SPECIAL", "B::sv_yes()");
+is(ref B::sv_no(), "B::SPECIAL", "B::sv_no()");
+is(ref B::sv_undef(), "B::SPECIAL", "B::sv_undef()");
+
+# More utility functions
+is(B::ppname(0), "pp_null", "Testing ppname (this might break if opnames.h is changed)");
+is(B::opnumber("null"), 0, "Testing opnumber with opname (null)");
+is(B::opnumber("pp_null"), 0, "Testing opnumber with opname (pp_null)");
+like(B::hash("wibble"), qr/0x[0-9a-f]*/, "Testing B::hash()");
+is(B::cstring("wibble"), '"wibble"', "Testing B::cstring()");
+is(B::perlstring("wibble"), '"wibble"', "Testing B::perlstring()");
+is(B::class(bless {}, "Wibble::Bibble"), "Bibble", "Testing B::class()");
+is(B::cast_I32(3.14), 3, "Testing B::cast_I32()");
+is(B::opnumber("localtime"), 294);