ddb9d9dc |
1 | #!./perl |
2 | |
3 | # |
4 | # test the bit operators '&', '|' and '^' |
5 | # |
6 | |
7 | print "1..9\n"; |
8 | |
9 | # numerics |
10 | print ((0xdead & 0xbeef) == 0x9ead ? "ok 1\n" : "not ok 1\n"); |
11 | print ((0xdead | 0xbeef) == 0xfeef ? "ok 2\n" : "not ok 2\n"); |
12 | print ((0xdead ^ 0xbeef) == 0x6042 ? "ok 3\n" : "not ok 3\n"); |
13 | |
14 | # short strings |
15 | print (("AAAAA" & "zzzzz") eq '@@@@@' ? "ok 4\n" : "not ok 4\n"); |
16 | print (("AAAAA" | "zzzzz") eq '{{{{{' ? "ok 5\n" : "not ok 5\n"); |
17 | print (("AAAAA" ^ "zzzzz") eq ';;;;;' ? "ok 6\n" : "not ok 6\n"); |
18 | |
19 | # long strings |
20 | $foo = "A" x 150; |
21 | $bar = "z" x 75; |
22 | print (($foo & $bar) eq ('@'x75 ) ? "ok 7\n" : "not ok 7\n"); |
23 | print (($foo | $bar) eq ('{'x75 . 'A'x75) ? "ok 8\n" : "not ok 8\n"); |
24 | print (($foo ^ $bar) eq (';'x75 . 'A'x75) ? "ok 9\n" : "not ok 9\n"); |