Annotation of embedaddon/php/ext/standard/tests/math/sqrt_variation.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test variations in usage of sqrt()
! 3: --INI--
! 4: precision = 14
! 5: --FILE--
! 6: <?php
! 7: /*
! 8: * proto float sqrt(float number)
! 9: * Function is implemented in ext/standard/math.c
! 10: */
! 11:
! 12:
! 13: //Test sqrt with a different input values
! 14: echo "*** Testing sqrt() : usage variations ***\n";
! 15:
! 16: $values = array(23,
! 17: -23,
! 18: 2.345e1,
! 19: -2.345e1,
! 20: 0x17,
! 21: 027,
! 22: "23",
! 23: "23.45",
! 24: "2.345e1",
! 25: "nonsense",
! 26: "1000",
! 27: "1000ABC",
! 28: null,
! 29: true,
! 30: false);
! 31:
! 32: for ($i = 0; $i < count($values); $i++) {
! 33: $res = sqrt($values[$i]);
! 34: var_dump($res);
! 35: }
! 36:
! 37: ?>
! 38: ===Done===
! 39: --EXPECTF--
! 40: *** Testing sqrt() : usage variations ***
! 41: float(4.7958315233127)
! 42: float(NAN)
! 43: float(4.8425200051213)
! 44: float(NAN)
! 45: float(4.7958315233127)
! 46: float(4.7958315233127)
! 47: float(4.7958315233127)
! 48: float(4.8425200051213)
! 49: float(4.8425200051213)
! 50:
! 51: Warning: sqrt() expects parameter 1 to be double, string given in %s on line %d
! 52: NULL
! 53: float(31.622776601684)
! 54:
! 55: Notice: A non well formed numeric value encountered in %s on line %d
! 56: float(31.622776601684)
! 57: float(0)
! 58: float(1)
! 59: float(0)
! 60: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>