This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix a2p translation of '{print "a" "b" "c"}'
[perl5.git] / t / op / bop.t
CommitLineData
ddb9d9dc
PP
1#!./perl
2
3#
4# test the bit operators '&', '|' and '^'
5#
6
7print "1..9\n";
8
9# numerics
10print ((0xdead & 0xbeef) == 0x9ead ? "ok 1\n" : "not ok 1\n");
11print ((0xdead | 0xbeef) == 0xfeef ? "ok 2\n" : "not ok 2\n");
12print ((0xdead ^ 0xbeef) == 0x6042 ? "ok 3\n" : "not ok 3\n");
13
14# short strings
15print (("AAAAA" & "zzzzz") eq '@@@@@' ? "ok 4\n" : "not ok 4\n");
16print (("AAAAA" | "zzzzz") eq '{{{{{' ? "ok 5\n" : "not ok 5\n");
17print (("AAAAA" ^ "zzzzz") eq ';;;;;' ? "ok 6\n" : "not ok 6\n");
18
19# long strings
20$foo = "A" x 150;
21$bar = "z" x 75;
22print (($foo & $bar) eq ('@'x75 ) ? "ok 7\n" : "not ok 7\n");
23print (($foo | $bar) eq ('{'x75 . 'A'x75) ? "ok 8\n" : "not ok 8\n");
24print (($foo ^ $bar) eq (';'x75 . 'A'x75) ? "ok 9\n" : "not ok 9\n");