From: Perl 5 Porters Date: Sun, 25 Aug 1996 00:23:01 +0000 (+0000) Subject: Support bit operations on strings longer than 15 bytes. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ddb9d9dc44a925e8debfb6b56dfdeb66a708607f;hp=a026971d0f28d48a093e5fdd42c475d75eb83b44;p=p5sagit%2Fp5-mst-13.2.git Support bit operations on strings longer than 15 bytes. --- diff --git a/t/op/bop.t b/t/op/bop.t new file mode 100644 index 0000000..8ebf8d3 --- /dev/null +++ b/t/op/bop.t @@ -0,0 +1,24 @@ +#!./perl + +# +# test the bit operators '&', '|' and '^' +# + +print "1..9\n"; + +# numerics +print ((0xdead & 0xbeef) == 0x9ead ? "ok 1\n" : "not ok 1\n"); +print ((0xdead | 0xbeef) == 0xfeef ? "ok 2\n" : "not ok 2\n"); +print ((0xdead ^ 0xbeef) == 0x6042 ? "ok 3\n" : "not ok 3\n"); + +# short strings +print (("AAAAA" & "zzzzz") eq '@@@@@' ? "ok 4\n" : "not ok 4\n"); +print (("AAAAA" | "zzzzz") eq '{{{{{' ? "ok 5\n" : "not ok 5\n"); +print (("AAAAA" ^ "zzzzz") eq ';;;;;' ? "ok 6\n" : "not ok 6\n"); + +# long strings +$foo = "A" x 150; +$bar = "z" x 75; +print (($foo & $bar) eq ('@'x75 ) ? "ok 7\n" : "not ok 7\n"); +print (($foo | $bar) eq ('{'x75 . 'A'x75) ? "ok 8\n" : "not ok 8\n"); +print (($foo ^ $bar) eq (';'x75 . 'A'x75) ? "ok 9\n" : "not ok 9\n");