Correct tests for B::{cstring,perlstring,cchar}
authorNicholas Clark <nick@ccl4.org>
Mon, 25 Oct 2010 07:46:53 +0000 (08:46 +0100)
committerNicholas Clark <nick@ccl4.org>
Mon, 25 Oct 2010 07:46:53 +0000 (08:46 +0100)
Fix a Perl precedence error that prevented several test cases for cchar() from
being run. As a result, fix those test cases.

Fix an ASCII assumption in the tests common to cstring() and perlstring().
(chr 127 is " on EBCDIC, which is most definitely printable, so won't be
replaced with octal there.)

ext/B/t/b.t

index 5bd4d18..614c8b2 100644 (file)
@@ -178,8 +178,8 @@ is(B::opnumber("pp_null"), 0, "Testing opnumber with opname (pp_null)");
     is(B::perlstring(undef), '0', "Testing B::perlstring(undef)");
 
     my @common = map {eval $_, $_}
-       '"wibble"', '"\""', '"\'"', '"\\\\"', '"\\n\\r\\t\\b\\a\\f"', '"\\177"',
-           '"\000"', '"\000\000"', '"\000Bing\000"';
+       '"wibble"', '"\""', '"\'"', '"\\\\"', '"\\n\\r\\t\\b\\a\\f"', '"\000"',
+           '"\000\000"', '"\000Bing\000"', ord 'N' == 78 ? '"\\177"' : ();
 
     my $oct = sprintf "\\%03o", ord '?';
     my @tests = (@common, '$_', '"$_"', '@_', '"@_"', '??N', qq{"$oct?N"},
@@ -200,9 +200,9 @@ is(B::opnumber("pp_null"), 0, "Testing opnumber with opname (pp_null)");
     }
 }
 {
-    my @tests = (map {eval(qq{"$_"}), $_} '\\n', '\\r', '\\t',
-                '\\b', '\\a', '\\f', '\\000', '\\\'', '?'), '"', '"',
-                ord 'N' == 78 ? (chr 11, q{'\013"'}, "\177", "'\\177'") : ();
+    my @tests = ((map {eval(qq{"$_"}), $_} '\\n', '\\r', '\\t',
+                 '\\b', '\\a', '\\f', '\\000', '\\\'', '?'), '"', '"',
+                ord 'N' == 78 ? (chr 11, '\v', "\177", '\\177') : ());
 
     while (my ($test, $expect) = splice @tests, 0, 2) {
        is(B::cchar($test), "'${expect}'", "B::cchar(qq{$expect})");