File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / json / tests / bug64874_part1.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Sun Jun 15 20:03:49 2014 UTC (10 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29, HEAD
php 5.4.29

--TEST--
Whitespace part of bug #64874 ("json_decode handles whitespace and case-sensitivity incorrectly")
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
function decode($json) {
    var_dump(json_decode($json));
    var_dump(json_last_error() !== 0);
    echo "\n";
}

// Leading whitespace should be ignored
decode(" true");
decode("\ttrue");
decode("\ntrue");
decode("\rtrue");

// So should trailing whitespace
decode("true ");
decode("true\t");
decode("true\n");
decode("true\r");

// And so should the combination of both
decode(" true ");
decode(" true\t");
decode(" true\n");
decode(" true\r");
decode("\ttrue ");
decode("\ttrue\t");
decode("\ttrue\n");
decode("\ttrue\r");
decode("\ntrue ");
decode("\ntrue\t");
decode("\ntrue\n");
decode("\ntrue\r");
decode("\rtrue ");
decode("\rtrue\t");
decode("\rtrue\n");
decode("\rtrue\r");

echo "Done\n";
--EXPECT--
bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

bool(true)
bool(false)

Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>