]> granicus.if.org Git - php/commitdiff
Use the same CS for all json tests
authorJakub Zelenka <bukka@php.net>
Sun, 15 Nov 2015 19:06:09 +0000 (19:06 +0000)
committerJakub Zelenka <bukka@php.net>
Sun, 15 Nov 2015 19:06:09 +0000 (19:06 +0000)
32 files changed:
ext/json/tests/002.phpt
ext/json/tests/006.phpt
ext/json/tests/007.phpt
ext/json/tests/bug40503.phpt
ext/json/tests/bug41034.phpt
ext/json/tests/bug41403.phpt
ext/json/tests/bug42785.phpt
ext/json/tests/bug46215.phpt
ext/json/tests/bug46944.phpt
ext/json/tests/bug47644.phpt
ext/json/tests/bug54058.phpt
ext/json/tests/bug54484.phpt
ext/json/tests/bug61978.phpt
ext/json/tests/bug62369.phpt
ext/json/tests/bug63737.phpt
ext/json/tests/bug64874_part1.phpt
ext/json/tests/bug64874_part2.phpt
ext/json/tests/bug66021.phpt
ext/json/tests/fail001.phpt
ext/json/tests/json_decode_basic.phpt
ext/json/tests/json_decode_error.phpt
ext/json/tests/json_encode_basic.phpt
ext/json/tests/json_encode_basic_utf8.phpt
ext/json/tests/json_encode_error.phpt
ext/json/tests/json_encode_numeric.phpt
ext/json/tests/json_last_error_error.phpt
ext/json/tests/json_last_error_msg_error.phpt
ext/json/tests/pass001.1.phpt
ext/json/tests/pass001.1_64bit.phpt
ext/json/tests/pass001.phpt
ext/json/tests/pass002.phpt
ext/json/tests/pass003.phpt

index 5959d4a5f3943af8a2d3875ce793ab9ce59fa30b..b562b616c8e06acdfb99bd13c29c3e73361bb513 100644 (file)
@@ -20,7 +20,6 @@ var_dump(json_encode(array(), JSON_FORCE_OBJECT));
 var_dump(json_encode(1));
 var_dump(json_encode("руссиш"));
 
-
 echo "Done\n";
 ?>
 --EXPECTF--    
index e1d4b4688902794d3e3e5daf56aa07ce38c8d9cd..da2fe009f1f1a96325d4ab09322372f65647ef60 100644 (file)
@@ -4,15 +4,14 @@ json_encode() & extended encoding
 <?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php
-
-$a = array('<foo>',"'bar'",'"baz"','&blong&');
+$a = array('<foo>', "'bar'", '"baz"', '&blong&');
 
 echo "Normal: ", json_encode($a), "\n";
-echo "Tags: ",   json_encode($a,JSON_HEX_TAG), "\n";
-echo "Apos: ",   json_encode($a,JSON_HEX_APOS), "\n";
-echo "Quot: ",   json_encode($a,JSON_HEX_QUOT), "\n";
-echo "Amp: ",    json_encode($a,JSON_HEX_AMP), "\n";
-echo "All: ",    json_encode($a,JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP), "\n";
+echo "Tags: ",   json_encode($a, JSON_HEX_TAG), "\n";
+echo "Apos: ",   json_encode($a, JSON_HEX_APOS), "\n";
+echo "Quot: ",   json_encode($a, JSON_HEX_QUOT), "\n";
+echo "Amp: ",    json_encode($a, JSON_HEX_AMP), "\n";
+echo "All: ",    json_encode($a, JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP), "\n";
 ?>
 --EXPECT--
 Normal: ["<foo>","'bar'","\"baz\"","&blong&"]
index 7557ac9ed7497c916c50b43ccb92354f61965ac3..008d1dd5de454e885aa9610c0c5b53dc70ace063 100644 (file)
@@ -15,7 +15,6 @@ var_dump(json_last_error(), json_last_error_msg());
 var_dump(json_decode("[1"));
 var_dump(json_last_error(), json_last_error_msg());
 
-
 echo "Done\n";
 ?>
 --EXPECT--
index 48f18a4e0f55751103b9d88beac766ef84db8a6b..387ba299ecd7c70798442ff409cf1b43232685ce 100644 (file)
@@ -6,14 +6,14 @@ precision=14
 <?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php
-function show_eq($x,$y) {
-       echo "$x ". ($x==$y ? "==" : "!=") ." $y\n";
+function json_test_show_eq($x, $y) {
+       echo "$x ". ( $x == $y ? "==" : "!=") ." $y\n";
 }
 
 $value = 0x7FFFFFFF; #2147483647;
-show_eq("$value", json_encode($value));
+json_test_show_eq("$value", json_encode($value));
 $value++;
-show_eq("$value", json_encode($value));
+json_test_show_eq("$value", json_encode($value));
 
 ?>
 --EXPECT--
index cc7704122d71248e23910abd6b26e459fe05057e..58ae281e6c40e7a0f6c635015d59f3bf5978f74d 100644 (file)
@@ -4,7 +4,7 @@ Bug #41034 (json_encode() ignores null byte started keys in arrays)
 <?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php
-echo json_encode(array(0,"\0ab"=>1,"\0null-prefixed value"));
+echo json_encode(array(0, "\0ab"=>1, "\0null-prefixed value"));
 echo "\nDone\n";
 ?>
 --EXPECT--
index 1a7343122a1450fe6f75ab7da8bbd2eb46c6d211..f0e5f3b511a300597878506e098359aefd447716 100644 (file)
@@ -2,9 +2,7 @@
 Bug #41403 (json_decode cannot decode floats if localeconv decimal_point is not '.')
 --SKIPIF--
 <?php
-
 if (!extension_loaded('json')) die('skip'); 
-
 if (setlocale(LC_NUMERIC, "de_DE") === false) {
        die("skip no de_DE locale");
 }
index 7bdadbed1e8472a4add683f51ac4760c384693d3..c4cda1196e4705536a1fc7607198c2dcd2fe2899 100644 (file)
@@ -2,20 +2,19 @@
 Bug #42785 (Incorrect formatting of double values with non-english locales)
 --SKIPIF--
 <?php
-       if (!extension_loaded("json")) {
-               print "skip"; 
-       } else if (!setlocale(LC_CTYPE, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1")) {
-               die("skip locale needed for this test is not supported on this platform");
-       }
+if (!extension_loaded('json')) die('skip');
+if (!setlocale(LC_CTYPE, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1")) {
+       die("skip locale needed for this test is not supported on this platform");
+}
 ?>
 --FILE--
 <?php
 setlocale(LC_ALL, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1");
 
-$foo = Array(100.10,"bar");
+$foo = array(100.10,"bar");
 var_dump(json_encode($foo));
 
-Class bar {}
+class bar {}
 $bar1 = new bar;
 $bar1->a = 100.10;
 $bar1->b = "foo";
index 0ac460cc15fde571f7c0828923ec756c2c4d44b9..be3a80f8600bdeb62ac22aa43eb549629f6efbb8 100644 (file)
@@ -1,16 +1,12 @@
 --TEST--
 Bug #46215 (json_encode mutates its parameter and has some class-specific state)
 --SKIPIF--
-<?php
-if (!extension_loaded("json")) {
-       die('skip JSON extension not available in this build');
-}       
-?>
+<?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php
 
 class foo {
-    protected $a = array();
+       protected $a = array();
 }
 
 $a = new foo;
index 812a548875766aca576aef99b5ba014a98610309..3d70f3ee11239548ed32e8a96b13a6652d0506e9 100644 (file)
@@ -6,8 +6,8 @@ Bug #46944 (json_encode() doesn't handle 3 byte utf8 correctly)
 <?php
 
 for ($i = 1; $i <= 16; $i++) {
-       $first = 0xf0|($i >> 2);
-       $second = 0x8f|($i & 3) << 4;
+       $first = 0xf0 | ($i >> 2);
+       $second = 0x8f | ($i & 3) << 4;
        $string = sprintf("aa%c%c\xbf\xbdzz", $first, $second);
        echo json_encode($string) . "\n";
 }
index 5e996b697308cc33dfa345ade743a508393033b1..85c4858af541ec7c1707c30dc15e1513f9613848 100644 (file)
@@ -2,8 +2,8 @@
 Bug #47644 (valid large integers are truncated)
 --SKIPIF--
 <?php
-  if (!extension_loaded('json')) die('skip: json extension not available');
-  if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+if (!extension_loaded('json')) die('skip');
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
 ?>
 --FILE--
 <?php
index df1b3130f8422a82e9dcdb724d0a46477ed5ef52..4b8773f93d93506fc0a26c99ea298e55b1273d9c 100644 (file)
@@ -22,8 +22,8 @@ json_encode($b);
 var_dump(json_last_error(), json_last_error_msg());
 
 $c = array(
-    'foo' => $bad_utf8,
-    'bar' => 1
+       'foo' => $bad_utf8,
+       'bar' => 1
 );
 json_encode($c);
 var_dump(json_last_error(), json_last_error_msg());
index d698ab5416420d6a664f5866a4819404782b9a3a..3a3847501990ca8c2ee2d090781b83e907e98db5 100644 (file)
@@ -10,11 +10,9 @@ var_dump(json_last_error());
 json_decode("");
 var_dump(json_last_error());
 
-
 json_decode("invalid json");
 var_dump(json_last_error());
 
-
 json_decode("");
 var_dump(json_last_error());
 ?>
index c34b03f8f7351419138cd856e62f5af32c0f3811..56b92dc6726a7bb88f07f14ff6938ada8ae10046 100644 (file)
@@ -6,25 +6,25 @@ Bug #61978 (Object recursion not detected for classes that implement JsonSeriali
 <?php
 
 class JsonTest1 {
-    public $test;
-    public $me;
-    public function __construct() {
-        $this->test = '123';
-        $this->me  = $this;
-    }
+       public $test;
+       public $me;
+       public function __construct() {
+               $this->test = '123';
+               $this->me  = $this;
+       }
 }
 
 class JsonTest2 implements JsonSerializable {
-    public $test;
-    public function __construct() {
-        $this->test = '123';
-    }
-    public function jsonSerialize() {
-        return array(
-            'test' => $this->test,
-            'me'   => $this
-        );
-    }
+       public $test;
+       public function __construct() {
+               $this->test = '123';
+       }
+       public function jsonSerialize() {
+               return array(
+                       'test' => $this->test,
+                       'me'   => $this
+               );
+       }
 }
 
 
index a5efd802c5ee6f563bdfd0d6e919c11bb2fc09cf..cf254bfc18bde42683ff58f908017474cad05936 100644 (file)
@@ -6,28 +6,28 @@ FR #62369 (Segfault on json_encode(deeply_nested_array)
 <?php
 
 $array = array();
-for ($i=0; $i<550; $i++) {
-    $array = array($array);
+for ($i=0; $i < 550; $i++) {
+       $array = array($array);
 }
 
 json_encode($array, 0, 551);
 switch (json_last_error()) {
-    case JSON_ERROR_NONE:
-        echo 'OK'.PHP_EOL;
-    break;
-    case JSON_ERROR_DEPTH:
-        echo 'ERROR'.PHP_EOL;
-    break;
+       case JSON_ERROR_NONE:
+               echo 'OK' . PHP_EOL;
+       break;
+       case JSON_ERROR_DEPTH:
+               echo 'ERROR' . PHP_EOL;
+       break;
 }
 
 json_encode($array, 0, 540);
 switch (json_last_error()) {
-    case JSON_ERROR_NONE:
-        echo 'OK'.PHP_EOL;
-    break;
-    case JSON_ERROR_DEPTH:
-        echo 'ERROR'.PHP_EOL;
-    break;
+       case JSON_ERROR_NONE:
+               echo 'OK' . PHP_EOL;
+       break;
+       case JSON_ERROR_DEPTH:
+               echo 'ERROR' . PHP_EOL;
+       break;
 }
 --EXPECTF--
 OK
index 1fb06d485e3fa5294894ca18f2cb2b31b25105aa..35361d850adc381297f509ed00b738069b785db1 100644 (file)
@@ -5,10 +5,10 @@ Bug #63737 (json_decode does not properly decode with options parameter)
 --FILE--
 <?php
 function decode($json) {
-    $x = json_decode($json);
-    var_dump($x);
-    $x = json_decode($json, false, 512, JSON_BIGINT_AS_STRING);
-    var_dump($x);
+       $x = json_decode($json);
+       var_dump($x);
+       $x = json_decode($json, false, 512, JSON_BIGINT_AS_STRING);
+       var_dump($x);
 }
 
 decode('123456789012345678901234567890');
index 6b79b8dc047edbcc8e54a56f6ffdacec3df390fb..9e0cb7e1cf4f9881f84997ba88965a2a8112d2e1 100644 (file)
@@ -5,9 +5,9 @@ Whitespace part of bug #64874 ("json_decode handles whitespace and case-sensitiv
 --FILE--
 <?php
 function decode($json) {
-    var_dump(json_decode($json));
-    var_dump(json_last_error() !== 0);
-    echo "\n";
+       var_dump(json_decode($json));
+       var_dump(json_last_error() !== 0);
+       echo "\n";
 }
 
 // Leading whitespace should be ignored
index 338fc1141abbe48adb2724f5100e258d478f9156..db784bd8e0ba14c211120e1dada787d975e6a509 100644 (file)
@@ -5,8 +5,8 @@ Case-sensitivity part of bug #64874 ("json_decode handles whitespace and case-se
 --FILE--
 <?php
 function decode($json) {
-    var_dump(json_decode($json));
-    echo ((json_last_error() !== 0) ? 'ERROR' : 'SUCCESS') . PHP_EOL;
+       var_dump(json_decode($json));
+       echo ((json_last_error() !== 0) ? 'ERROR' : 'SUCCESS') . PHP_EOL;
 }
 
 // Only lowercase should work
index cf52e0c6df3ae93b62402a1e769c627bb8fe61e4..504d17fc78e662237024bd91ae5ef95f4fb0de3e 100644 (file)
@@ -9,7 +9,7 @@ class Foo {
        private $bar = 'baz';
 }
 
-echo json_encode([[], (object)[], new Foo], JSON_PRETTY_PRINT), "\n";
+echo json_encode(array(array(), (object) array(), new Foo), JSON_PRETTY_PRINT);
 
 ?>
 --EXPECT--
index 1bf9f121067f3c539962baccf31848100ffc88a7..ea203746a6daf3f85ae859e32de1b7a20fb7eaf8 100644 (file)
@@ -2,43 +2,44 @@
 JSON (http://www.crockford.com/JSON/JSON_checker/test/fail*.json)
 --SKIPIF--
 <?php
-  if (!extension_loaded('json')) die('skip: json extension not available');
+  if (!extension_loaded('json')) die('skip');
 ?>
 --FILE--
 <?php
     
-$tests = array('"A JSON payload should be an object or array, not a string."',
-               '["Unclosed array"',
-               '{unquoted_key: "keys must be quoted}',
-               '["extra comma",]',
-               '["double extra comma",,]',
-               '[   , "<-- missing value"]',
-               '["Comma after the close"],',
-               '["Extra close"]]',
-               '{"Extra comma": true,}',
-               '{"Extra value after close": true} "misplaced quoted value"',
-               '{"Illegal expression": 1 + 2}',
-               '{"Illegal invocation": alert()}',
-               '{"Numbers cannot have leading zeroes": 013}',
-               '{"Numbers cannot be hex": 0x14}',
-               '["Illegal backslash escape: \\x15"]',
-               '["Illegal backslash escape: \\\'"]',
-               '["Illegal backslash escape: \\017"]',
-               '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]',
-               '{"Missing colon" null}',
-               '{"Double colon":: null}',
-               '{"Comma instead of colon", null}',
-               '["Colon instead of comma": false]',
-               '["Bad value", truth]',
-               "['single quote']");
+$tests = array(
+       '"A JSON payload should be an object or array, not a string."',
+       '["Unclosed array"',
+       '{unquoted_key: "keys must be quoted}',
+       '["extra comma",]',
+       '["double extra comma",,]',
+       '[   , "<-- missing value"]',
+       '["Comma after the close"],',
+       '["Extra close"]]',
+       '{"Extra comma": true,}',
+       '{"Extra value after close": true} "misplaced quoted value"',
+       '{"Illegal expression": 1 + 2}',
+       '{"Illegal invocation": alert()}',
+       '{"Numbers cannot have leading zeroes": 013}',
+       '{"Numbers cannot be hex": 0x14}',
+       '["Illegal backslash escape: \\x15"]',
+       '["Illegal backslash escape: \\\'"]',
+       '["Illegal backslash escape: \\017"]',
+       '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]',
+       '{"Missing colon" null}',
+       '{"Double colon":: null}',
+       '{"Comma instead of colon", null}',
+       '["Colon instead of comma": false]',
+       '["Bad value", truth]',
+       "['single quote']"
+);
 
-foreach ($tests as $test)
-{
-    echo 'Testing: ' . $test . "\n";
-    echo "AS OBJECT\n";
-    var_dump(json_decode($test));
-    echo "AS ARRAY\n";
-    var_dump(json_decode($test, true));
+foreach ($tests as $test) {
+       echo 'Testing: ' . $test . "\n";
+       echo "AS OBJECT\n";
+       var_dump(json_decode($test));
+       echo "AS ARRAY\n";
+       var_dump(json_decode($test, true));
 }
 
 ?>
index 6dbeadb36751717e90f6d3bfab661a00887d04c2..0bc939c25733baf70111813ad252420c465afdf9 100644 (file)
@@ -1,50 +1,41 @@
 --TEST--
 Test json_decode() 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  : mixed json_decode  ( string $json  [, bool $assoc  ] )
- * Description: Decodes a JSON string
- * Source code: ext/json/php_json.c
- * Alias to functions: 
- */
 echo "*** Testing json_decode() : basic functionality ***\n";
 
 // array with different values for $string
 $inputs =  array (
-               '0',
-               '123',
-               '-123',
-               '2147483647',
-               '-2147483648',
-               '123.456',
-               '1230',
-               '-1230',
-               'true',
-               'false',
-               'null',
-               '"abc"',
-               '"Hello World\r\n"',
-               '[]',
-               '[1,2,3,4,5]',
-               '{"myInt":99,"myFloat":123.45,"myNull":null,"myBool":true,"myString":"Hello World"}',
-               '{"Jan":31,"Feb":29,"Mar":31,"April":30,"May":31,"June":30}',
-               '""',
-               '{}'
+       '0',
+       '123',
+       '-123',
+       '2147483647',
+       '-2147483648',
+       '123.456',
+       '1230',
+       '-1230',
+       'true',
+       'false',
+       'null',
+       '"abc"',
+       '"Hello World\r\n"',
+       '[]',
+       '[1,2,3,4,5]',
+       '{"myInt":99,"myFloat":123.45,"myNull":null,"myBool":true,"myString":"Hello World"}',
+       '{"Jan":31,"Feb":29,"Mar":31,"April":30,"May":31,"June":30}',
+       '""',
+       '{}'
 );  
 
 // loop through with each element of the $inputs array to test json_decode() function
 $count = 1;
 foreach($inputs as $input) {
-  echo "-- Iteration $count --\n";     
-  var_dump(json_decode($input)); 
-   var_dump(json_decode($input, TRUE)); 
-  $count ++;
+       echo "-- Iteration $count --\n";
+       var_dump(json_decode($input));
+       var_dump(json_decode($input, true));
+       $count++;
 }
 
 ?>
index 4d5d4e4bee7e9545e93f106a698908b6de9f0c8f..90a42889a038b1f7c55a8110717a48976eed78fb 100644 (file)
@@ -1,26 +1,17 @@
 --TEST--
 Test json_decode() function : error conditions
 --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  : mixed json_decode  ( string $json  [, bool $assoc=false  [, int $depth=512  ]] )
- * Description: Decodes a JSON string
- * Source code: ext/json/php_json.c
- * Alias to functions: 
- */
 echo "*** Testing json_decode() : error conditions ***\n";
 
 echo "\n-- Testing json_decode() function with no arguments --\n";
-var_dump( json_decode() );
+var_dump(json_decode());
 
 echo "\n-- Testing json_decode() function with more than expected no. of arguments --\n";
 $extra_arg = 10;
-var_dump( json_decode('"abc"', TRUE, 512, 0, $extra_arg) );
+var_dump(json_decode('"abc"', true, 512, 0, $extra_arg));
 
 ?>
 ===Done===
index fc348eed8112c560e825c2190e797b12e43d2cd8..7fe855d1dc97713cf4b7af22337302e9ca66a5a6 100644 (file)
@@ -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 ++;
 }
 
 ?>
index a8e8b425efb4e25e351dc1370f8ea01885abb4d4..d03e83a8a9e0c61e959c769fc700ae532beffe4a 100644 (file)
@@ -1,18 +1,9 @@
 --TEST--
 Test json_encode() function : basic functionality with UTF8 string input
 --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 with UTF-8 input***\n";
 
 $utf8_string = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
index 547c8bef17bf5ea552740fa84aea0e965d4255fd..defc7b474ca52c74250f6cae25ebcf35f018edaa 100644 (file)
@@ -1,27 +1,17 @@
 --TEST--
 Test json_encode() function : error conditions
 --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  [, int $options=0  ] )
- * Description: Returns the JSON representation of a value
- * Source code: ext/json/php_json.c
- * Alias to functions: 
- */
-
 echo "*** Testing json_encode() : error conditions ***\n";
 
 echo "\n-- Testing json_encode() function with no arguments --\n";
-var_dump( json_encode() );
+var_dump(json_encode());
 
 echo "\n-- Testing json_encode() function with more than expected no. of arguments --\n";
 $extra_arg = 10;
-var_dump( json_encode("abc", 0, $extra_arg) );
+var_dump(json_encode("abc", 0, $extra_arg));
 
 ?>
 ===Done===
index 5392350194f2a2dad30aab60f364d7a208d0dcfe..5850c4c959697e4e312e7af43166bc350f1f3104 100644 (file)
@@ -1,11 +1,7 @@
 --TEST--
 Test json_encode() function with numeric flag
 --SKIPIF--
-<?php
-if (!extension_loaded("json")) {
-       die('skip JSON extension not available in this build');
-}       
-?>
+<?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php
 var_dump(
index bb00388a2e66bc54db277ddd3b6e62c29f207a84..9b520ed9a7e75e596737c9f77b4292759a961328 100644 (file)
@@ -1,15 +1,14 @@
 --TEST--
 json_last_error() failures
 --SKIPIF--
-<?php !extension_loaded('json') && die('skip json extension not available') ?>
+<?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php
 
 var_dump(json_last_error());
-var_dump(json_last_error(TRUE));
+var_dump(json_last_error(true));
 var_dump(json_last_error('some', 4, 'args', 'here'));
 
-
 ?>
 --EXPECTF--
 int(0)
index 8135cf1dede6fae0b80ca6b55195dd3d16b44cf8..1a5f9d1bda83e7bb30c4773ea1e937841ce06338 100644 (file)
@@ -1,12 +1,12 @@
 --TEST--
 json_last_error_msg() failures
 --SKIPIF--
-<?php !extension_loaded('json') && die('skip json extension not available') ?>
+<?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php
 
 var_dump(json_last_error_msg());
-var_dump(json_last_error_msg(TRUE));
+var_dump(json_last_error_msg(true));
 var_dump(json_last_error_msg('some', 4, 'args', 'here'));
 
 ?>
index a51f885780d7420a5992fabfb896809b0e6600c4..611c40c4a412f5e73287b458aaf3c27ab42e2d61 100644 (file)
@@ -4,8 +4,8 @@ JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json)
 precision=14
 --SKIPIF--
 <?php
-  if (!extension_loaded('json')) die('skip: json extension not available');
-  if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+if (!extension_loaded('json')) die('skip');
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
 ?>
 --FILE--
 <?php
index ff2714436d0567b0e48385d44306350d75bb068c..e6666d15993005f3a4b9bc3b4b9be18976b6e359 100644 (file)
@@ -4,8 +4,8 @@ JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json)
 precision=14
 --SKIPIF--
 <?php
-  if (!extension_loaded('json')) die('skip: json extension not available');
-  if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+if (!extension_loaded('json')) die('skip');
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
 ?>
 --FILE--
 <?php
index 1fd05fcdd870596d473431cb78823431768b52f9..ffe7c61f01d8f24688ed61198b4bcd90e96c2bf2 100644 (file)
@@ -4,7 +4,7 @@ JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json)
 precision=14
 --SKIPIF--
 <?php
-  if (!extension_loaded('json')) die('skip: json extension not available');
+if (!extension_loaded('json')) die('skip');
 ?>
 --FILE--
 <?php
index 24c7e3358003463939246b1a8d9eb9333207dbaf..aa61cf5396354568895ab15ea41c364c2e6a518b 100644 (file)
@@ -1,9 +1,7 @@
 --TEST--
 JSON (http://www.crockford.com/JSON/JSON_checker/test/pass2.json)
 --SKIPIF--
-<?php
-  if (!extension_loaded('json')) die('skip: json extension not available');
-?>
+<?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php
     
index 36da4a1de6a11edc4a53937482c50a5aa577baae..5e8c1664d05d57833bee77b367d01bcaff2cfddd 100644 (file)
@@ -1,9 +1,7 @@
 --TEST--
 JSON (http://www.crockford.com/JSON/JSON_checker/test/pass3.json)
 --SKIPIF--
-<?php
-  if (!extension_loaded('json')) die('skip: json extension not available');
-?>
+<?php if (!extension_loaded("json")) print "skip"; ?>
 --FILE--
 <?php