diff options
author | SVN Migration <svn@php.net> | 2006-10-15 21:09:28 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2006-10-15 21:09:28 +0000 |
commit | 88ec761548b66f58acc1a86cdd0fc164ca925476 (patch) | |
tree | d0af978fa00d83bb1d82c613f66477fbd6bb18aa /ext/json/tests | |
parent | 268984b4787e797db6054313fc9ba3b9e845306e (diff) | |
download | php-git-PECL_OPENSSL.tar.gz |
This commit was manufactured by cvs2svn to create branch 'PECL_OPENSSL'.PECL_OPENSSL
Diffstat (limited to 'ext/json/tests')
-rw-r--r-- | ext/json/tests/001.phpt | 71 | ||||
-rw-r--r-- | ext/json/tests/002.phpt | 28 | ||||
-rw-r--r-- | ext/json/tests/003.phpt | 33 | ||||
-rw-r--r-- | ext/json/tests/004.phpt | 27 | ||||
-rw-r--r-- | ext/json/tests/005.phpt | 27 | ||||
-rw-r--r-- | ext/json/tests/fail001.phpt | 165 | ||||
-rw-r--r-- | ext/json/tests/pass001.1.phpt | 895 | ||||
-rw-r--r-- | ext/json/tests/pass001.phpt | 708 | ||||
-rw-r--r-- | ext/json/tests/pass002.phpt | 275 | ||||
-rw-r--r-- | ext/json/tests/pass003.phpt | 94 |
10 files changed, 0 insertions, 2323 deletions
diff --git a/ext/json/tests/001.phpt b/ext/json/tests/001.phpt deleted file mode 100644 index 095aedf631..0000000000 --- a/ext/json/tests/001.phpt +++ /dev/null @@ -1,71 +0,0 @@ ---TEST-- -json_decode() tests ---SKIPIF-- -<?php if (!extension_loaded("json")) print "skip"; ?> ---FILE-- -<?php - -var_dump(json_decode()); -var_dump(json_decode("")); -var_dump(json_decode("", 1)); -var_dump(json_decode("", 0)); -var_dump(json_decode(".", 1)); -var_dump(json_decode(".", 0)); -var_dump(json_decode("<?>")); -var_dump(json_decode(";")); -var_dump(json_decode("руссиш")); -var_dump(json_decode("blah")); -var_dump(json_decode(NULL)); -var_dump(json_decode('{ "test": { "foo": "bar" } }')); -var_dump(json_decode('{ "test": { "foo": "" } }')); -var_dump(json_decode('{ "": { "foo": "" } }')); -var_dump(json_decode('{ "": { "": "" } }')); -var_dump(json_decode('{ "": { "": "" }')); -var_dump(json_decode('{ "": "": "" } }')); - -echo "Done\n"; -?> ---EXPECTF-- -Warning: json_decode() expects at least 1 parameter, 0 given in %s on line %d -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -NULL -object(stdClass)#1 (1) { - ["test"]=> - object(stdClass)#2 (1) { - ["foo"]=> - string(3) "bar" - } -} -object(stdClass)#1 (1) { - ["test"]=> - object(stdClass)#2 (1) { - ["foo"]=> - string(0) "" - } -} -object(stdClass)#1 (1) { - ["_empty_"]=> - object(stdClass)#2 (1) { - ["foo"]=> - string(0) "" - } -} -object(stdClass)#1 (1) { - ["_empty_"]=> - object(stdClass)#2 (1) { - ["_empty_"]=> - string(0) "" - } -} -NULL -NULL -Done diff --git a/ext/json/tests/002.phpt b/ext/json/tests/002.phpt deleted file mode 100644 index 5bc29bc5b9..0000000000 --- a/ext/json/tests/002.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -json_encode() tests ---SKIPIF-- -<?php if (!extension_loaded("json")) print "skip"; ?> ---FILE-- -<?php - -var_dump(json_encode("")); -var_dump(json_encode(NULL)); -var_dump(json_encode(TRUE)); -var_dump(json_encode(array(""=>""))); -var_dump(json_encode(array(array(1)))); - -var_dump(json_encode(1)); -var_dump(json_encode("руссиш")); - - -echo "Done\n"; -?> ---EXPECTF-- -string(2) """" -string(4) "null" -string(4) "true" -string(2) "{}" -string(5) "[[1]]" -string(1) "1" -string(38) ""\u0440\u0443\u0441\u0441\u0438\u0448"" -Done diff --git a/ext/json/tests/003.phpt b/ext/json/tests/003.phpt deleted file mode 100644 index f10baa9d12..0000000000 --- a/ext/json/tests/003.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -json_encode() & endless loop - 1 ---SKIPIF-- -<?php if (!extension_loaded("json")) print "skip"; ?> ---FILE-- -<?php - -$a = array(); -$a[] = &$a; - -var_dump($a); -var_dump(json_encode($a)); - -/* Break circular data structure to prevent memory leaks */ -unset($a[0]); - -echo "Done\n"; -?> ---EXPECTF-- -array(1) { - [0]=> - &array(1) { - [0]=> - &array(1) { - [0]=> - *RECURSION* - } - } -} - -Warning: json_encode(): recursion detected in %s on line %d -string(8) "[[null]]" -Done diff --git a/ext/json/tests/004.phpt b/ext/json/tests/004.phpt deleted file mode 100644 index 884d874205..0000000000 --- a/ext/json/tests/004.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -json_encode() & endless loop - 2 ---SKIPIF-- -<?php if (!extension_loaded("json")) print "skip"; ?> ---FILE-- -<?php - -$a = new stdclass; -$a->prop = $a; - -var_dump($a); -var_dump(json_encode($a)); - -echo "Done\n"; -?> ---EXPECTF-- -object(stdClass)#%d (1) { - ["prop"]=> - object(stdClass)#%d (1) { - ["prop"]=> - *RECURSION* - } -} - -Warning: json_encode(): recursion detected in %s on line %d -string(22) "{"prop":{"prop":null}}" -Done diff --git a/ext/json/tests/005.phpt b/ext/json/tests/005.phpt deleted file mode 100644 index f6a8977d18..0000000000 --- a/ext/json/tests/005.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -json_encode() & endless loop - 3 ---SKIPIF-- -<?php if (!extension_loaded("json")) print "skip"; ?> ---FILE-- -<?php - -$a = array(); -$a[] = $a; - -var_dump($a); -var_dump(json_encode($a)); - -echo "Done\n"; -?> ---EXPECTF-- -array(1) { - [0]=> - array(1) { - [0]=> - *RECURSION* - } -} - -Warning: json_encode(): recursion detected in %s on line %d -string(8) "[[null]]" -Done diff --git a/ext/json/tests/fail001.phpt b/ext/json/tests/fail001.phpt deleted file mode 100644 index f0e0afa387..0000000000 --- a/ext/json/tests/fail001.phpt +++ /dev/null @@ -1,165 +0,0 @@ ---TEST-- -JSON (http://www.crockford.com/JSON/JSON_checker/test/fail*.json) ---SKIPIF-- -<?php - if (!extension_loaded('json')) die('skip: json extension not available'); -?> ---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']"); - -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)); -} - -?> ---EXPECT-- -Testing: "A JSON payload should be an object or array, not a string." -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["Unclosed array" -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {unquoted_key: "keys must be quoted} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["extra comma",] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["double extra comma",,] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: [ , "<-- missing value"] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["Comma after the close"], -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["Extra close"]] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Extra comma": true,} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Extra value after close": true} "misplaced quoted value" -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Illegal expression": 1 + 2} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Illegal invocation": alert()} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Numbers cannot have leading zeroes": 013} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Numbers cannot be hex": 0x14} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["Illegal backslash escape: \x15"] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["Illegal backslash escape: \'"] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["Illegal backslash escape: \017"] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: [[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Missing colon" null} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Double colon":: null} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: {"Comma instead of colon", null} -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["Colon instead of comma": false] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ["Bad value", truth] -AS OBJECT -NULL -AS ARRAY -NULL -Testing: ['single quote'] -AS OBJECT -NULL -AS ARRAY -NULL diff --git a/ext/json/tests/pass001.1.phpt b/ext/json/tests/pass001.1.phpt deleted file mode 100644 index 87766e912c..0000000000 --- a/ext/json/tests/pass001.1.phpt +++ /dev/null @@ -1,895 +0,0 @@ ---TEST-- -JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json) ---SKIPIF-- -<?php - if (!extension_loaded('json')) die('skip: json extension not available'); -?> ---FILE-- -<?php -/* Modified to test unescaped UNICODE as keys and values. - * Modified to test numbers with exponents without a decimal point. - * Modified to test empty string values. - * Modified to test a mix of integers and strings as keys. - */ -// Expect warnings about INF. -ini_set("error_reporting", E_ALL & ~E_WARNING); - -$test = " -[ - \"JSON Test Pattern pass1\", - {\"object with 1 member\":[\"array with 1 element\"]}, - {}, - [], - -42, - true, - false, - null, - { - \"integer\": 1234567890, - \"real\": -9876.543210, - \"e\": 0.123456789e-12, - \"E\": 1.234567890E+34, - \"\": 23456789012E666, - \"E no .\": 4E12, - \"zero\": 0, - \"one\": 1, - \"space\": \" \", - \"quote\": \"\\\"\", - \"backslash\": \"\\\\\", - \"controls\": \"\\b\\f\\n\\r\\t\", - \"slash\": \"/ & \\/\", - \"alpha\": \"abcdefghijklmnopqrstuvwyz\", - \"ALPHA\": \"ABCDEFGHIJKLMNOPQRSTUVWYZ\", - \"digit\": \"0123456789\", - \"special\": \"`1~!@#$%^&*()_+-={':[,]}|;.</>?\", - \"hex\": \"\\u0123\\u4567\\u89AB\\uCDEF\\uabcd\\uef4A\", - \"unicode\": \"\\u30d7\\u30ec\\u30b9\\u30ad\\u30c3\\u30c8\", - \"プレスキット\": \"プレスキット\", - \"empty_string\": \"\", - \"true\": true, - \"false\": false, - \"null\": null, - \"array\":[ ], - \"object\":{ }, - \"123\":{\"456\":{\"abc\":{\"789\":\"def\",\"012\":[1,2,\"5\",500],\"ghi\":[1,2,\"five\",50,\"sixty\"]}}}, - \"address\": \"50 St. James Street\", - \"url\": \"http://www.JSON.org/\", - \"comment\": \"// /* <!-- --\", - \"# -- --> */\": \" \", - \" s p a c e d \" :[1,2 , 3 - -, - -4 , 5 , 6 ,7 ], - \"compact\": [1,2,3,4,5,6,7], - \"jsontext\": \"{\\\"object with 1 member\\\":[\\\"array with 1 element\\\"]}\", - \"quotes\": \"" \\u0022 %22 0x22 034 "\", - \"\\/\\\\\\\"\\uCAFE\\uBABE\\uAB98\\uFCDE\\ubcda\\uef4A\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?\" -: \"A key can be any string\" - }, - 0.5 ,98.6 -, -99.44 -, - -1066 - - -,\"rosebud\"] -"; - -echo 'Testing: ' . $test . "\n"; -echo "DECODE: AS OBJECT\n"; -$obj = json_decode($test); -var_dump($obj); -echo "DECODE: AS ARRAY\n"; -$arr = json_decode($test, true); -var_dump($arr); - -echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj); -echo $obj_enc . "\n"; -echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr); -echo $arr_enc . "\n"; - -echo "DECODE AGAIN: AS OBJECT\n"; -$obj = json_decode($obj_enc); -var_dump($obj); -echo "DECODE AGAIN: AS ARRAY\n"; -$arr = json_decode($arr_enc, true); -var_dump($arr); - -?> ---EXPECT-- -Testing: -[ - "JSON Test Pattern pass1", - {"object with 1 member":["array with 1 element"]}, - {}, - [], - -42, - true, - false, - null, - { - "integer": 1234567890, - "real": -9876.543210, - "e": 0.123456789e-12, - "E": 1.234567890E+34, - "": 23456789012E666, - "E no .": 4E12, - "zero": 0, - "one": 1, - "space": " ", - "quote": "\"", - "backslash": "\\", - "controls": "\b\f\n\r\t", - "slash": "/ & \/", - "alpha": "abcdefghijklmnopqrstuvwyz", - "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", - "digit": "0123456789", - "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?", - "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", - "unicode": "\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8", - "プレスキット": "プレスキット", - "empty_string": "", - "true": true, - "false": false, - "null": null, - "array":[ ], - "object":{ }, - "123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}}, - "address": "50 St. James Street", - "url": "http://www.JSON.org/", - "comment": "// /* <!-- --", - "# -- --> */": " ", - " s p a c e d " :[1,2 , 3 - -, - -4 , 5 , 6 ,7 ], - "compact": [1,2,3,4,5,6,7], - "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", - "quotes": "" \u0022 %22 0x22 034 "", - "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" -: "A key can be any string" - }, - 0.5 ,98.6 -, -99.44 -, - -1066 - - -,"rosebud"] - -DECODE: AS OBJECT -array(14) { - [0]=> - string(23) "JSON Test Pattern pass1" - [1]=> - object(stdClass)#1 (1) { - ["object with 1 member"]=> - array(1) { - [0]=> - string(20) "array with 1 element" - } - } - [2]=> - object(stdClass)#2 (0) { - } - [3]=> - array(0) { - } - [4]=> - int(-42) - [5]=> - bool(true) - [6]=> - bool(false) - [7]=> - NULL - [8]=> - object(stdClass)#3 (36) { - ["integer"]=> - int(1234567890) - ["real"]=> - float(-9876.54321) - ["e"]=> - float(1.23456789E-13) - ["E"]=> - float(1.23456789E+34) - ["_empty_"]=> - float(INF) - ["E no ."]=> - float(4.0E+12) - ["zero"]=> - int(0) - ["one"]=> - int(1) - ["space"]=> - string(1) " " - ["quote"]=> - string(1) """ - ["backslash"]=> - string(1) "\" - ["controls"]=> - string(5) " - - " - ["slash"]=> - string(5) "/ & /" - ["alpha"]=> - string(25) "abcdefghijklmnopqrstuvwyz" - ["ALPHA"]=> - string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ" - ["digit"]=> - string(10) "0123456789" - ["special"]=> - string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?" - ["hex"]=> - string(17) "ģ䕧覫췯ꯍ" - ["unicode"]=> - string(18) "プレスキット" - ["プレスキット"]=> - string(18) "プレスキット" - ["empty_string"]=> - string(0) "" - ["true"]=> - bool(true) - ["false"]=> - bool(false) - ["null"]=> - NULL - ["array"]=> - array(0) { - } - ["object"]=> - object(stdClass)#4 (0) { - } - ["123"]=> - object(stdClass)#5 (1) { - ["456"]=> - object(stdClass)#6 (1) { - ["abc"]=> - object(stdClass)#7 (3) { - ["789"]=> - string(3) "def" - ["012"]=> - array(4) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - string(1) "5" - [3]=> - int(500) - } - ["ghi"]=> - array(5) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - string(4) "five" - [3]=> - int(50) - [4]=> - string(5) "sixty" - } - } - } - } - ["address"]=> - string(19) "50 St. James Street" - ["url"]=> - string(20) "http://www.JSON.org/" - ["comment"]=> - string(13) "// /* <!-- --" - ["# -- --> */"]=> - string(1) " " - [" s p a c e d "]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["compact"]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["jsontext"]=> - string(49) "{"object with 1 member":["array with 1 element"]}" - ["quotes"]=> - string(27) "" " %22 0x22 034 "" - ["/\"쫾몾ꮘﳞ볚 - - `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=> - string(23) "A key can be any string" - } - [9]=> - float(0.5) - [10]=> - float(98.6) - [11]=> - float(99.44) - [12]=> - int(1066) - [13]=> - string(7) "rosebud" -} -DECODE: AS ARRAY -array(14) { - [0]=> - string(23) "JSON Test Pattern pass1" - [1]=> - array(1) { - ["object with 1 member"]=> - array(1) { - [0]=> - string(20) "array with 1 element" - } - } - [2]=> - array(0) { - } - [3]=> - array(0) { - } - [4]=> - int(-42) - [5]=> - bool(true) - [6]=> - bool(false) - [7]=> - NULL - [8]=> - array(36) { - ["integer"]=> - int(1234567890) - ["real"]=> - float(-9876.54321) - ["e"]=> - float(1.23456789E-13) - ["E"]=> - float(1.23456789E+34) - ["_empty_"]=> - float(INF) - ["E no ."]=> - float(4.0E+12) - ["zero"]=> - int(0) - ["one"]=> - int(1) - ["space"]=> - string(1) " " - ["quote"]=> - string(1) """ - ["backslash"]=> - string(1) "\" - ["controls"]=> - string(5) " - - " - ["slash"]=> - string(5) "/ & /" - ["alpha"]=> - string(25) "abcdefghijklmnopqrstuvwyz" - ["ALPHA"]=> - string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ" - ["digit"]=> - string(10) "0123456789" - ["special"]=> - string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?" - ["hex"]=> - string(17) "ģ䕧覫췯ꯍ" - ["unicode"]=> - string(18) "プレスキット" - ["プレスキット"]=> - string(18) "プレスキット" - ["empty_string"]=> - string(0) "" - ["true"]=> - bool(true) - ["false"]=> - bool(false) - ["null"]=> - NULL - ["array"]=> - array(0) { - } - ["object"]=> - array(0) { - } - [123]=> - array(1) { - [456]=> - array(1) { - ["abc"]=> - array(3) { - [789]=> - string(3) "def" - ["012"]=> - array(4) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - string(1) "5" - [3]=> - int(500) - } - ["ghi"]=> - array(5) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - string(4) "five" - [3]=> - int(50) - [4]=> - string(5) "sixty" - } - } - } - } - ["address"]=> - string(19) "50 St. James Street" - ["url"]=> - string(20) "http://www.JSON.org/" - ["comment"]=> - string(13) "// /* <!-- --" - ["# -- --> */"]=> - string(1) " " - [" s p a c e d "]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["compact"]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["jsontext"]=> - string(49) "{"object with 1 member":["array with 1 element"]}" - ["quotes"]=> - string(27) "" " %22 0x22 034 "" - ["/\"쫾몾ꮘﳞ볚 - - `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=> - string(23) "A key can be any string" - } - [9]=> - float(0.5) - [10]=> - float(98.6) - [11]=> - float(99.44) - [12]=> - int(1066) - [13]=> - string(7) "rosebud" -} -ENCODE: FROM OBJECT -["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"E no .":4.0e+12,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":{},"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"" \" %22 0x22 034 "","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"] -ENCODE: FROM ARRAY -["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},[],[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"E no .":4.0e+12,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":[],"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"" \" %22 0x22 034 "","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"] -DECODE AGAIN: AS OBJECT -array(14) { - [0]=> - string(23) "JSON Test Pattern pass1" - [1]=> - object(stdClass)#8 (1) { - ["object with 1 member"]=> - array(1) { - [0]=> - string(20) "array with 1 element" - } - } - [2]=> - object(stdClass)#9 (0) { - } - [3]=> - array(0) { - } - [4]=> - int(-42) - [5]=> - bool(true) - [6]=> - bool(false) - [7]=> - NULL - [8]=> - object(stdClass)#10 (36) { - ["integer"]=> - int(1234567890) - ["real"]=> - float(-9876.54321) - ["e"]=> - float(1.23456789E-13) - ["E"]=> - float(1.23456789E+34) - ["_empty_"]=> - int(0) - ["E no ."]=> - float(4.0E+12) - ["zero"]=> - int(0) - ["one"]=> - int(1) - ["space"]=> - string(1) " " - ["quote"]=> - string(1) """ - ["backslash"]=> - string(1) "\" - ["controls"]=> - string(5) " - - " - ["slash"]=> - string(5) "/ & /" - ["alpha"]=> - string(25) "abcdefghijklmnopqrstuvwyz" - ["ALPHA"]=> - string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ" - ["digit"]=> - string(10) "0123456789" - ["special"]=> - string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?" - ["hex"]=> - string(17) "ģ䕧覫췯ꯍ" - ["unicode"]=> - string(18) "プレスキット" - ["プレスキット"]=> - string(18) "プレスキット" - ["empty_string"]=> - string(0) "" - ["true"]=> - bool(true) - ["false"]=> - bool(false) - ["null"]=> - NULL - ["array"]=> - array(0) { - } - ["object"]=> - object(stdClass)#11 (0) { - } - ["123"]=> - object(stdClass)#12 (1) { - ["456"]=> - object(stdClass)#13 (1) { - ["abc"]=> - object(stdClass)#14 (3) { - ["789"]=> - string(3) "def" - ["012"]=> - array(4) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - string(1) "5" - [3]=> - int(500) - } - ["ghi"]=> - array(5) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - string(4) "five" - [3]=> - int(50) - [4]=> - string(5) "sixty" - } - } - } - } - ["address"]=> - string(19) "50 St. James Street" - ["url"]=> - string(20) "http://www.JSON.org/" - ["comment"]=> - string(13) "// /* <!-- --" - ["# -- --> */"]=> - string(1) " " - [" s p a c e d "]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["compact"]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["jsontext"]=> - string(49) "{"object with 1 member":["array with 1 element"]}" - ["quotes"]=> - string(27) "" " %22 0x22 034 "" - ["/\"쫾몾ꮘﳞ볚 - - `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=> - string(23) "A key can be any string" - } - [9]=> - float(0.5) - [10]=> - float(98.6) - [11]=> - float(99.44) - [12]=> - int(1066) - [13]=> - string(7) "rosebud" -} -DECODE AGAIN: AS ARRAY -array(14) { - [0]=> - string(23) "JSON Test Pattern pass1" - [1]=> - array(1) { - ["object with 1 member"]=> - array(1) { - [0]=> - string(20) "array with 1 element" - } - } - [2]=> - array(0) { - } - [3]=> - array(0) { - } - [4]=> - int(-42) - [5]=> - bool(true) - [6]=> - bool(false) - [7]=> - NULL - [8]=> - array(36) { - ["integer"]=> - int(1234567890) - ["real"]=> - float(-9876.54321) - ["e"]=> - float(1.23456789E-13) - ["E"]=> - float(1.23456789E+34) - ["_empty_"]=> - int(0) - ["E no ."]=> - float(4.0E+12) - ["zero"]=> - int(0) - ["one"]=> - int(1) - ["space"]=> - string(1) " " - ["quote"]=> - string(1) """ - ["backslash"]=> - string(1) "\" - ["controls"]=> - string(5) " - - " - ["slash"]=> - string(5) "/ & /" - ["alpha"]=> - string(25) "abcdefghijklmnopqrstuvwyz" - ["ALPHA"]=> - string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ" - ["digit"]=> - string(10) "0123456789" - ["special"]=> - string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?" - ["hex"]=> - string(17) "ģ䕧覫췯ꯍ" - ["unicode"]=> - string(18) "プレスキット" - ["プレスキット"]=> - string(18) "プレスキット" - ["empty_string"]=> - string(0) "" - ["true"]=> - bool(true) - ["false"]=> - bool(false) - ["null"]=> - NULL - ["array"]=> - array(0) { - } - ["object"]=> - array(0) { - } - [123]=> - array(1) { - [456]=> - array(1) { - ["abc"]=> - array(3) { - [789]=> - string(3) "def" - ["012"]=> - array(4) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - string(1) "5" - [3]=> - int(500) - } - ["ghi"]=> - array(5) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - string(4) "five" - [3]=> - int(50) - [4]=> - string(5) "sixty" - } - } - } - } - ["address"]=> - string(19) "50 St. James Street" - ["url"]=> - string(20) "http://www.JSON.org/" - ["comment"]=> - string(13) "// /* <!-- --" - ["# -- --> */"]=> - string(1) " " - [" s p a c e d "]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["compact"]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["jsontext"]=> - string(49) "{"object with 1 member":["array with 1 element"]}" - ["quotes"]=> - string(27) "" " %22 0x22 034 "" - ["/\"쫾몾ꮘﳞ볚 - - `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=> - string(23) "A key can be any string" - } - [9]=> - float(0.5) - [10]=> - float(98.6) - [11]=> - float(99.44) - [12]=> - int(1066) - [13]=> - string(7) "rosebud" -} diff --git a/ext/json/tests/pass001.phpt b/ext/json/tests/pass001.phpt deleted file mode 100644 index f2aba683b0..0000000000 --- a/ext/json/tests/pass001.phpt +++ /dev/null @@ -1,708 +0,0 @@ ---TEST-- -JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json) ---SKIPIF-- -<?php - if (!extension_loaded('json')) die('skip: json extension not available'); -?> ---FILE-- -<?php -// Expect warnings about INF. -ini_set("error_reporting", E_ALL & ~E_WARNING); - -$test = " -[ - \"JSON Test Pattern pass1\", - {\"object with 1 member\":[\"array with 1 element\"]}, - {}, - [], - -42, - true, - false, - null, - { - \"integer\": 1234567890, - \"real\": -9876.543210, - \"e\": 0.123456789e-12, - \"E\": 1.234567890E+34, - \"\": 23456789012E666, - \"zero\": 0, - \"one\": 1, - \"space\": \" \", - \"quote\": \"\\\"\", - \"backslash\": \"\\\\\", - \"controls\": \"\\b\\f\\n\\r\\t\", - \"slash\": \"/ & \\/\", - \"alpha\": \"abcdefghijklmnopqrstuvwyz\", - \"ALPHA\": \"ABCDEFGHIJKLMNOPQRSTUVWYZ\", - \"digit\": \"0123456789\", - \"special\": \"`1~!@#$%^&*()_+-={':[,]}|;.</>?\", - \"hex\": \"\\u0123\\u4567\\u89AB\\uCDEF\\uabcd\\uef4A\", - \"true\": true, - \"false\": false, - \"null\": null, - \"array\":[ ], - \"object\":{ }, - \"address\": \"50 St. James Street\", - \"url\": \"http://www.JSON.org/\", - \"comment\": \"// /* <!-- --\", - \"# -- --> */\": \" \", - \" s p a c e d \" :[1,2 , 3 - -, - -4 , 5 , 6 ,7 ], - \"compact\": [1,2,3,4,5,6,7], - \"jsontext\": \"{\\\"object with 1 member\\\":[\\\"array with 1 element\\\"]}\", - \"quotes\": \"" \\u0022 %22 0x22 034 "\", - \"\\/\\\\\\\"\\uCAFE\\uBABE\\uAB98\\uFCDE\\ubcda\\uef4A\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?\" -: \"A key can be any string\" - }, - 0.5 ,98.6 -, -99.44 -, - -1066 - - -,\"rosebud\"] -"; - -echo 'Testing: ' . $test . "\n"; -echo "DECODE: AS OBJECT\n"; -$obj = json_decode($test); -var_dump($obj); -echo "DECODE: AS ARRAY\n"; -$arr = json_decode($test, true); -var_dump($arr); - -echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj); -echo $obj_enc . "\n"; -echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr); -echo $arr_enc . "\n"; - -echo "DECODE AGAIN: AS OBJECT\n"; -$obj = json_decode($obj_enc); -var_dump($obj); -echo "DECODE AGAIN: AS ARRAY\n"; -$arr = json_decode($arr_enc, true); -var_dump($arr); - -?> ---EXPECT-- -Testing: -[ - "JSON Test Pattern pass1", - {"object with 1 member":["array with 1 element"]}, - {}, - [], - -42, - true, - false, - null, - { - "integer": 1234567890, - "real": -9876.543210, - "e": 0.123456789e-12, - "E": 1.234567890E+34, - "": 23456789012E666, - "zero": 0, - "one": 1, - "space": " ", - "quote": "\"", - "backslash": "\\", - "controls": "\b\f\n\r\t", - "slash": "/ & \/", - "alpha": "abcdefghijklmnopqrstuvwyz", - "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", - "digit": "0123456789", - "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?", - "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", - "true": true, - "false": false, - "null": null, - "array":[ ], - "object":{ }, - "address": "50 St. James Street", - "url": "http://www.JSON.org/", - "comment": "// /* <!-- --", - "# -- --> */": " ", - " s p a c e d " :[1,2 , 3 - -, - -4 , 5 , 6 ,7 ], - "compact": [1,2,3,4,5,6,7], - "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", - "quotes": "" \u0022 %22 0x22 034 "", - "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" -: "A key can be any string" - }, - 0.5 ,98.6 -, -99.44 -, - -1066 - - -,"rosebud"] - -DECODE: AS OBJECT -array(14) { - [0]=> - string(23) "JSON Test Pattern pass1" - [1]=> - object(stdClass)#1 (1) { - ["object with 1 member"]=> - array(1) { - [0]=> - string(20) "array with 1 element" - } - } - [2]=> - object(stdClass)#2 (0) { - } - [3]=> - array(0) { - } - [4]=> - int(-42) - [5]=> - bool(true) - [6]=> - bool(false) - [7]=> - NULL - [8]=> - object(stdClass)#3 (31) { - ["integer"]=> - int(1234567890) - ["real"]=> - float(-9876.54321) - ["e"]=> - float(1.23456789E-13) - ["E"]=> - float(1.23456789E+34) - ["_empty_"]=> - float(INF) - ["zero"]=> - int(0) - ["one"]=> - int(1) - ["space"]=> - string(1) " " - ["quote"]=> - string(1) """ - ["backslash"]=> - string(1) "\" - ["controls"]=> - string(5) " - - " - ["slash"]=> - string(5) "/ & /" - ["alpha"]=> - string(25) "abcdefghijklmnopqrstuvwyz" - ["ALPHA"]=> - string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ" - ["digit"]=> - string(10) "0123456789" - ["special"]=> - string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?" - ["hex"]=> - string(17) "ģ䕧覫췯ꯍ" - ["true"]=> - bool(true) - ["false"]=> - bool(false) - ["null"]=> - NULL - ["array"]=> - array(0) { - } - ["object"]=> - object(stdClass)#4 (0) { - } - ["address"]=> - string(19) "50 St. James Street" - ["url"]=> - string(20) "http://www.JSON.org/" - ["comment"]=> - string(13) "// /* <!-- --" - ["# -- --> */"]=> - string(1) " " - [" s p a c e d "]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["compact"]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["jsontext"]=> - string(49) "{"object with 1 member":["array with 1 element"]}" - ["quotes"]=> - string(27) "" " %22 0x22 034 "" - ["/\"쫾몾ꮘﳞ볚 - - `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=> - string(23) "A key can be any string" - } - [9]=> - float(0.5) - [10]=> - float(98.6) - [11]=> - float(99.44) - [12]=> - int(1066) - [13]=> - string(7) "rosebud" -} -DECODE: AS ARRAY -array(14) { - [0]=> - string(23) "JSON Test Pattern pass1" - [1]=> - array(1) { - ["object with 1 member"]=> - array(1) { - [0]=> - string(20) "array with 1 element" - } - } - [2]=> - array(0) { - } - [3]=> - array(0) { - } - [4]=> - int(-42) - [5]=> - bool(true) - [6]=> - bool(false) - [7]=> - NULL - [8]=> - array(31) { - ["integer"]=> - int(1234567890) - ["real"]=> - float(-9876.54321) - ["e"]=> - float(1.23456789E-13) - ["E"]=> - float(1.23456789E+34) - ["_empty_"]=> - float(INF) - ["zero"]=> - int(0) - ["one"]=> - int(1) - ["space"]=> - string(1) " " - ["quote"]=> - string(1) """ - ["backslash"]=> - string(1) "\" - ["controls"]=> - string(5) " - - " - ["slash"]=> - string(5) "/ & /" - ["alpha"]=> - string(25) "abcdefghijklmnopqrstuvwyz" - ["ALPHA"]=> - string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ" - ["digit"]=> - string(10) "0123456789" - ["special"]=> - string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?" - ["hex"]=> - string(17) "ģ䕧覫췯ꯍ" - ["true"]=> - bool(true) - ["false"]=> - bool(false) - ["null"]=> - NULL - ["array"]=> - array(0) { - } - ["object"]=> - array(0) { - } - ["address"]=> - string(19) "50 St. James Street" - ["url"]=> - string(20) "http://www.JSON.org/" - ["comment"]=> - string(13) "// /* <!-- --" - ["# -- --> */"]=> - string(1) " " - [" s p a c e d "]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["compact"]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["jsontext"]=> - string(49) "{"object with 1 member":["array with 1 element"]}" - ["quotes"]=> - string(27) "" " %22 0x22 034 "" - ["/\"쫾몾ꮘﳞ볚 - - `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=> - string(23) "A key can be any string" - } - [9]=> - float(0.5) - [10]=> - float(98.6) - [11]=> - float(99.44) - [12]=> - int(1066) - [13]=> - string(7) "rosebud" -} -ENCODE: FROM OBJECT -["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","true":true,"false":false,"null":null,"array":[],"object":{},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"" \" %22 0x22 034 "","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"] -ENCODE: FROM ARRAY -["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},[],[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","true":true,"false":false,"null":null,"array":[],"object":[],"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"" \" %22 0x22 034 "","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"] -DECODE AGAIN: AS OBJECT -array(14) { - [0]=> - string(23) "JSON Test Pattern pass1" - [1]=> - object(stdClass)#5 (1) { - ["object with 1 member"]=> - array(1) { - [0]=> - string(20) "array with 1 element" - } - } - [2]=> - object(stdClass)#6 (0) { - } - [3]=> - array(0) { - } - [4]=> - int(-42) - [5]=> - bool(true) - [6]=> - bool(false) - [7]=> - NULL - [8]=> - object(stdClass)#7 (31) { - ["integer"]=> - int(1234567890) - ["real"]=> - float(-9876.54321) - ["e"]=> - float(1.23456789E-13) - ["E"]=> - float(1.23456789E+34) - ["_empty_"]=> - int(0) - ["zero"]=> - int(0) - ["one"]=> - int(1) - ["space"]=> - string(1) " " - ["quote"]=> - string(1) """ - ["backslash"]=> - string(1) "\" - ["controls"]=> - string(5) " - - " - ["slash"]=> - string(5) "/ & /" - ["alpha"]=> - string(25) "abcdefghijklmnopqrstuvwyz" - ["ALPHA"]=> - string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ" - ["digit"]=> - string(10) "0123456789" - ["special"]=> - string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?" - ["hex"]=> - string(17) "ģ䕧覫췯ꯍ" - ["true"]=> - bool(true) - ["false"]=> - bool(false) - ["null"]=> - NULL - ["array"]=> - array(0) { - } - ["object"]=> - object(stdClass)#8 (0) { - } - ["address"]=> - string(19) "50 St. James Street" - ["url"]=> - string(20) "http://www.JSON.org/" - ["comment"]=> - string(13) "// /* <!-- --" - ["# -- --> */"]=> - string(1) " " - [" s p a c e d "]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["compact"]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["jsontext"]=> - string(49) "{"object with 1 member":["array with 1 element"]}" - ["quotes"]=> - string(27) "" " %22 0x22 034 "" - ["/\"쫾몾ꮘﳞ볚 - - `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=> - string(23) "A key can be any string" - } - [9]=> - float(0.5) - [10]=> - float(98.6) - [11]=> - float(99.44) - [12]=> - int(1066) - [13]=> - string(7) "rosebud" -} -DECODE AGAIN: AS ARRAY -array(14) { - [0]=> - string(23) "JSON Test Pattern pass1" - [1]=> - array(1) { - ["object with 1 member"]=> - array(1) { - [0]=> - string(20) "array with 1 element" - } - } - [2]=> - array(0) { - } - [3]=> - array(0) { - } - [4]=> - int(-42) - [5]=> - bool(true) - [6]=> - bool(false) - [7]=> - NULL - [8]=> - array(31) { - ["integer"]=> - int(1234567890) - ["real"]=> - float(-9876.54321) - ["e"]=> - float(1.23456789E-13) - ["E"]=> - float(1.23456789E+34) - ["_empty_"]=> - int(0) - ["zero"]=> - int(0) - ["one"]=> - int(1) - ["space"]=> - string(1) " " - ["quote"]=> - string(1) """ - ["backslash"]=> - string(1) "\" - ["controls"]=> - string(5) " - - " - ["slash"]=> - string(5) "/ & /" - ["alpha"]=> - string(25) "abcdefghijklmnopqrstuvwyz" - ["ALPHA"]=> - string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ" - ["digit"]=> - string(10) "0123456789" - ["special"]=> - string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?" - ["hex"]=> - string(17) "ģ䕧覫췯ꯍ" - ["true"]=> - bool(true) - ["false"]=> - bool(false) - ["null"]=> - NULL - ["array"]=> - array(0) { - } - ["object"]=> - array(0) { - } - ["address"]=> - string(19) "50 St. James Street" - ["url"]=> - string(20) "http://www.JSON.org/" - ["comment"]=> - string(13) "// /* <!-- --" - ["# -- --> */"]=> - string(1) " " - [" s p a c e d "]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["compact"]=> - array(7) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - } - ["jsontext"]=> - string(49) "{"object with 1 member":["array with 1 element"]}" - ["quotes"]=> - string(27) "" " %22 0x22 034 "" - ["/\"쫾몾ꮘﳞ볚 - - `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=> - string(23) "A key can be any string" - } - [9]=> - float(0.5) - [10]=> - float(98.6) - [11]=> - float(99.44) - [12]=> - int(1066) - [13]=> - string(7) "rosebud" -} diff --git a/ext/json/tests/pass002.phpt b/ext/json/tests/pass002.phpt deleted file mode 100644 index 24c7e33580..0000000000 --- a/ext/json/tests/pass002.phpt +++ /dev/null @@ -1,275 +0,0 @@ ---TEST-- -JSON (http://www.crockford.com/JSON/JSON_checker/test/pass2.json) ---SKIPIF-- -<?php - if (!extension_loaded('json')) die('skip: json extension not available'); -?> ---FILE-- -<?php - -$test = '[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]'; -echo 'Testing: ' . $test . "\n"; -echo "DECODE: AS OBJECT\n"; -$obj = json_decode($test); -var_dump($obj); -echo "DECODE: AS ARRAY\n"; -$arr = json_decode($test, true); -var_dump($arr); - -echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj); -echo $obj_enc . "\n"; -echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr); -echo $arr_enc . "\n"; - -echo "DECODE AGAIN: AS OBJECT\n"; -$obj = json_decode($obj_enc); -var_dump($obj); -echo "DECODE AGAIN: AS ARRAY\n"; -$arr = json_decode($arr_enc, true); -var_dump($arr); - -?> ---EXPECT-- -Testing: [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] -DECODE: AS OBJECT -array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - string(12) "Not too deep" - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -} -DECODE: AS ARRAY -array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - string(12) "Not too deep" - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -} -ENCODE: FROM OBJECT -[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] -ENCODE: FROM ARRAY -[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] -DECODE AGAIN: AS OBJECT -array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - string(12) "Not too deep" - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -} -DECODE AGAIN: AS ARRAY -array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - array(1) { - [0]=> - string(12) "Not too deep" - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -} diff --git a/ext/json/tests/pass003.phpt b/ext/json/tests/pass003.phpt deleted file mode 100644 index 36da4a1de6..0000000000 --- a/ext/json/tests/pass003.phpt +++ /dev/null @@ -1,94 +0,0 @@ ---TEST-- -JSON (http://www.crockford.com/JSON/JSON_checker/test/pass3.json) ---SKIPIF-- -<?php - if (!extension_loaded('json')) die('skip: json extension not available'); -?> ---FILE-- -<?php - -$test = ' -{ - "JSON Test Pattern pass3": { - "The outermost value": "must be an object or array.", - "In this test": "It is an object." - } -} -'; - -echo 'Testing: ' . $test . "\n"; -echo "DECODE: AS OBJECT\n"; -$obj = json_decode($test); -var_dump($obj); -echo "DECODE: AS ARRAY\n"; -$arr = json_decode($test, true); -var_dump($arr); - -echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj); -echo $obj_enc . "\n"; -echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr); -echo $arr_enc . "\n"; - -echo "DECODE AGAIN: AS OBJECT\n"; -$obj = json_decode($obj_enc); -var_dump($obj); -echo "DECODE AGAIN: AS ARRAY\n"; -$arr = json_decode($arr_enc, true); -var_dump($arr); - -?> ---EXPECT-- -Testing: -{ - "JSON Test Pattern pass3": { - "The outermost value": "must be an object or array.", - "In this test": "It is an object." - } -} - -DECODE: AS OBJECT -object(stdClass)#1 (1) { - ["JSON Test Pattern pass3"]=> - object(stdClass)#2 (2) { - ["The outermost value"]=> - string(27) "must be an object or array." - ["In this test"]=> - string(16) "It is an object." - } -} -DECODE: AS ARRAY -array(1) { - ["JSON Test Pattern pass3"]=> - array(2) { - ["The outermost value"]=> - string(27) "must be an object or array." - ["In this test"]=> - string(16) "It is an object." - } -} -ENCODE: FROM OBJECT -{"JSON Test Pattern pass3":{"The outermost value":"must be an object or array.","In this test":"It is an object."}} -ENCODE: FROM ARRAY -{"JSON Test Pattern pass3":{"The outermost value":"must be an object or array.","In this test":"It is an object."}} -DECODE AGAIN: AS OBJECT -object(stdClass)#3 (1) { - ["JSON Test Pattern pass3"]=> - object(stdClass)#4 (2) { - ["The outermost value"]=> - string(27) "must be an object or array." - ["In this test"]=> - string(16) "It is an object." - } -} -DECODE AGAIN: AS ARRAY -array(1) { - ["JSON Test Pattern pass3"]=> - array(2) { - ["The outermost value"]=> - string(27) "must be an object or array." - ["In this test"]=> - string(16) "It is an object." - } -} |