xref: /PHP-8.0/ext/gmp/tests/gmp_or.phpt (revision 65f14b0d)
1--TEST--
2gmp_or() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_or("111111", "2222222")));
9var_dump(gmp_strval(gmp_or(123123, 435234)));
10var_dump(gmp_strval(gmp_or(555, "2342341123")));
11var_dump(gmp_strval(gmp_or(-1, 3333)));
12var_dump(gmp_strval(gmp_or(4545, -20)));
13
14try {
15    var_dump(gmp_strval(gmp_or("test", "no test")));
16} catch (\ValueError $e) {
17    echo $e->getMessage() . \PHP_EOL;
18}
19
20$n = gmp_init("987657876543456");
21var_dump(gmp_strval(gmp_or($n, "34332")));
22$n1 = gmp_init("987657878765436543456");
23var_dump(gmp_strval(gmp_or($n, $n1)));
24
25try {
26    var_dump(gmp_or(array(), 1));
27} catch (\TypeError $e) {
28    echo $e->getMessage() . \PHP_EOL;
29}
30try {
31    var_dump(gmp_or(1, array()));
32} catch (\TypeError $e) {
33    echo $e->getMessage() . \PHP_EOL;
34}
35try {
36    var_dump(gmp_or(array(), array()));
37} catch (\TypeError $e) {
38    echo $e->getMessage() . \PHP_EOL;
39}
40
41echo "Done\n";
42?>
43--EXPECT--
44string(7) "2226831"
45string(6) "517363"
46string(10) "2342341163"
47string(2) "-1"
48string(3) "-19"
49gmp_or(): Argument #1 ($num1) is not an integer string
50string(15) "987657876576252"
51string(21) "987658441719689394144"
52gmp_or(): Argument #1 ($num1) must be of type GMP|string|int, array given
53gmp_or(): Argument #2 ($num2) must be of type GMP|string|int, array given
54gmp_or(): Argument #1 ($num1) must be of type GMP|string|int, array given
55Done
56