xref: /PHP-7.2/ext/gmp/tests/gmp_sqrt.phpt (revision 17ccbeec)
1--TEST--
2gmp_sqrt() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_sqrt(-2)));
9var_dump(gmp_strval(gmp_sqrt("-2")));
10var_dump(gmp_strval(gmp_sqrt("0")));
11var_dump(gmp_strval(gmp_sqrt("2")));
12var_dump(gmp_strval(gmp_sqrt("144")));
13
14$n = gmp_init(0);
15var_dump(gmp_strval(gmp_sqrt($n)));
16$n = gmp_init(-144);
17var_dump(gmp_strval(gmp_sqrt($n)));
18$n = gmp_init(777);
19var_dump(gmp_strval(gmp_sqrt($n)));
20
21var_dump(gmp_sqrt($n, 1));
22var_dump(gmp_sqrt());
23var_dump(gmp_sqrt(array()));
24
25echo "Done\n";
26?>
27--EXPECTF--
28Warning: gmp_sqrt(): Number has to be greater than or equal to 0 in %s on line %d
29string(1) "0"
30
31Warning: gmp_sqrt(): Number has to be greater than or equal to 0 in %s on line %d
32string(1) "0"
33string(1) "0"
34string(1) "1"
35string(2) "12"
36string(1) "0"
37
38Warning: gmp_sqrt(): Number has to be greater than or equal to 0 in %s on line %d
39string(1) "0"
40string(2) "27"
41
42Warning: gmp_sqrt() expects exactly 1 parameter, 2 given in %s on line %d
43NULL
44
45Warning: gmp_sqrt() expects exactly 1 parameter, 0 given in %s on line %d
46NULL
47
48Warning: gmp_sqrt(): Unable to convert variable to GMP - wrong type in %s on line %d
49bool(false)
50Done
51