summaryrefslogtreecommitdiff
path: root/ext/json/tests/json_encode_basic.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/json/tests/json_encode_basic.phpt')
-rw-r--r--ext/json/tests/json_encode_basic.phpt98
1 files changed, 44 insertions, 54 deletions
diff --git a/ext/json/tests/json_encode_basic.phpt b/ext/json/tests/json_encode_basic.phpt
index fc348eed81..7fe855d1dc 100644
--- a/ext/json/tests/json_encode_basic.phpt
+++ b/ext/json/tests/json_encode_basic.phpt
@@ -1,18 +1,9 @@
--TEST--
Test json_encode() function : basic functionality
--SKIPIF--
-<?php
-if (!extension_loaded("json")) {
- die('skip JSON extension not available in this build');
-}
-?>
+<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
-/* Prototype : string json_encode ( mixed $value )
- * Description: Returns the JSON representation of a value
- * Source code: ext/json/php_json.c
- * Alias to functions:
- */
echo "*** Testing json_encode() : basic functionality ***\n";
//get an unset variable
@@ -35,64 +26,63 @@ $obj->MyString = "Hello World";
// array with different values for $string
$inputs = array (
+ // integers
+ 0,
+ 123,
+ -123,
+ 2147483647,
+ -2147483648,
- // integers
-/*1*/ 0,
- 123,
- -123,
- 2147483647,
- -2147483648,
+ // floats
+ 123.456,
+ 1.23E3,
+ -1.23E3,
- // floats
-/*6*/ 123.456,
- 1.23E3,
- -1.23E3,
-
- // boolean
-/*9*/ TRUE,
- true,
- FALSE,
- false,
+ // boolean
+ TRUE,
+ true,
+ FALSE,
+ false,
- // NULL
-/*13*/ NULL,
- null,
-
- // strings
-/*15*/ "abc",
- 'abc',
- "Hello\t\tWorld\n",
+ // NULL
+ NULL,
+ null,
- // arrays
-/*18*/ array(),
- array(1,2,3,4,5),
- array(1 => "Sun", 2=>"Mon", 3 => "Tue", 4 => "Wed", 5 => "Thur", 6 => "Fri", 7 => "Sat"),
- array("Jan" => 31, "Feb" => 29, "Mar" => 31, "April" => 30, "May" => 31, "June" => 30),
-
- // empty data
-/*22*/ "",
- '',
+ // strings
+ "abc",
+ 'abc',
+ "Hello\t\tWorld\n",
+
+ // arrays
+ array(),
+ array(1,2,3,4,5),
+ array(1 => "Sun", 2 => "Mon", 3 => "Tue", 4 => "Wed", 5 => "Thur", 6 => "Fri", 7 => "Sat"),
+ array("Jan" => 31, "Feb" => 29, "Mar" => 31, "April" => 30, "May" => 31, "June" => 30),
+
+ // empty data
+ "",
+ '',
- // undefined data
-/*24*/ @$undefined_var,
+ // undefined data
+ @$undefined_var,
- // unset data
-/*25*/ @$unset_var,
+ // unset data
+ @$unset_var,
- // resource variable
-/*26*/ $fp,
+ // resource variable
+ $fp,
- // object variable
-/*27*/ $obj
+ // object variable
+ $obj
);
// loop through with each element of the $inputs array to test json_encode() function
$count = 1;
foreach($inputs as $input) {
- echo "-- Iteration $count --\n";
- var_dump(json_encode($input));
- $count ++;
+ echo "-- Iteration $count --\n";
+ var_dump(json_encode($input));
+ $count ++;
}
?>