Annotation of embedaddon/php/ext/json/tests/json_decode_error.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test json_decode() function : error conditions
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded("json")) {
! 6: die('skip JSON extension not available in this build');
! 7: }
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: /* Prototype : mixed json_decode ( string $json [, bool $assoc=false [, int $depth=512 ]] )
! 12: * Description: Decodes a JSON string
! 13: * Source code: ext/json/php_json.c
! 14: * Alias to functions:
! 15: */
! 16: echo "*** Testing json_decode() : error conditions ***\n";
! 17:
! 18: echo "\n-- Testing json_decode() function with no arguments --\n";
! 19: var_dump( json_decode() );
! 20:
! 21: echo "\n-- Testing json_decode() function with more than expected no. of arguments --\n";
! 22: $extra_arg = 10;
! 23: var_dump( json_decode('"abc"', TRUE, 512, $extra_arg) );
! 24:
! 25: ?>
! 26: ===Done===
! 27: --EXPECTF--
! 28: *** Testing json_decode() : error conditions ***
! 29:
! 30: -- Testing json_decode() function with no arguments --
! 31:
! 32: Warning: json_decode() expects at least 1 parameter, 0 given in %s on line %d
! 33: NULL
! 34:
! 35: -- Testing json_decode() function with more than expected no. of arguments --
! 36:
! 37: Warning: json_decode() expects at most 3 parameters, 4 given in %s on line %d
! 38: NULL
! 39: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>