This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Exact path to perl for open -|.
[perl5.git] / t / op / oct.t
1 #!./perl
2
3 print "1..36\n";
4
5 print +(oct('0b10101') ==          0b10101) ? "ok" : "not ok", " 1\n";
6 print +(oct('0b10101') ==              025) ? "ok" : "not ok", " 2\n";
7 print +(oct('0b10101') ==               21) ? "ok" : "not ok", " 3\n";
8 print +(oct('0b10101') ==             0x15) ? "ok" : "not ok", " 4\n";
9
10 print +(oct('b10101')  ==          0b10101) ? "ok" : "not ok", " 5\n";
11 print +(oct('b10101')  ==              025) ? "ok" : "not ok", " 6\n";
12 print +(oct('b10101')  ==               21) ? "ok" : "not ok", " 7\n";
13 print +(oct('b10101')  ==             0x15) ? "ok" : "not ok", " 8\n";
14
15 print +(oct('01234')   ==     0b1010011100) ? "ok" : "not ok", " 9\n";
16 print +(oct('01234')   ==            01234) ? "ok" : "not ok", " 10\n";
17 print +(oct('01234')   ==              668) ? "ok" : "not ok", " 11\n";
18 print +(oct('01234')   ==            0x29c) ? "ok" : "not ok", " 12\n";
19
20 print +(oct('0x1234')  ==  0b1001000110100) ? "ok" : "not ok", " 13\n";
21 print +(oct('0x1234')  ==           011064) ? "ok" : "not ok", " 14\n";
22 print +(oct('0x1234')  ==             4660) ? "ok" : "not ok", " 15\n";
23 print +(oct('0x1234')  ==           0x1234) ? "ok" : "not ok", " 16\n";
24
25 print +(oct('x1234')   ==  0b1001000110100) ? "ok" : "not ok", " 17\n";
26 print +(oct('x1234')   ==           011064) ? "ok" : "not ok", " 18\n";
27 print +(oct('x1234')   ==             4660) ? "ok" : "not ok", " 19\n";
28 print +(oct('x1234')   ==           0x1234) ? "ok" : "not ok", " 20\n";
29
30 print +(hex('01234')   ==  0b1001000110100) ? "ok" : "not ok", " 21\n";
31 print +(hex('01234')   ==           011064) ? "ok" : "not ok", " 22\n";
32 print +(hex('01234')   ==             4660) ? "ok" : "not ok", " 23\n";
33 print +(hex('01234')   ==           0x1234) ? "ok" : "not ok", " 24\n";
34
35 print +(hex('0x1234')  ==  0b1001000110100) ? "ok" : "not ok", " 25\n";
36 print +(hex('0x1234')  ==           011064) ? "ok" : "not ok", " 26\n";
37 print +(hex('0x1234')  ==             4660) ? "ok" : "not ok", " 27\n";
38 print +(hex('0x1234')  ==           0x1234) ? "ok" : "not ok", " 28\n";
39
40 print +(hex('x1234')   ==  0b1001000110100) ? "ok" : "not ok", " 29\n";
41 print +(hex('x1234')   ==           011064) ? "ok" : "not ok", " 30\n";
42 print +(hex('x1234')   ==             4660) ? "ok" : "not ok", " 31\n";
43 print +(hex('x1234')   ==           0x1234) ? "ok" : "not ok", " 32\n";
44
45 print +(oct('0b11111111111111111111111111111111') == 4294967295) ?
46     "ok" : "not ok", " 33\n";
47 print +(oct('037777777777')                       == 4294967295) ?
48     "ok" : "not ok", " 34\n";
49 print +(oct('0xffffffff')                         == 4294967295) ?
50     "ok" : "not ok", " 35\n";
51
52 print +(hex('0xffffffff')                         == 4294967295) ?
53     "ok" : "not ok", " 36\n";