summaryrefslogtreecommitdiff
path: root/t/op/bop.t
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-08-25 00:23:01 +0000
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1996-08-25 00:23:01 +0000
commitddb9d9dc44a925e8debfb6b56dfdeb66a708607f (patch)
tree7be378109a85e30128652998a1aaaeff0522e80d /t/op/bop.t
parenta026971d0f28d48a093e5fdd42c475d75eb83b44 (diff)
downloadperl-ddb9d9dc44a925e8debfb6b56dfdeb66a708607f.tar.gz
Support bit operations on strings longer than 15 bytes.
Diffstat (limited to 't/op/bop.t')
-rw-r--r--t/op/bop.t24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/op/bop.t b/t/op/bop.t
new file mode 100644
index 0000000000..8ebf8d3eeb
--- /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");