From fd0175cb994025b5704c524bcd7ee89e93e4cb1c Mon Sep 17 00:00:00 2001 From: LamGC Date: Thu, 15 Oct 2026 09:49:31 +0800 Subject: [PATCH] test: add isolated resource-budget experiment experiment/php/scanner-tests.php --- experiment/php/scanner-tests.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 experiment/php/scanner-tests.php diff --git a/experiment/php/scanner-tests.php b/experiment/php/scanner-tests.php new file mode 100644 index 0000000..47f96d1 --- /dev/null +++ b/experiment/php/scanner-tests.php @@ -0,0 +1,16 @@ +'[[{{,:', 'escaped'=>'\\"[{]}\\\\"','arr'=>array(0,'"'))),2,7) +); +foreach($cases as $case){$r=preflight_budget($case[0]);check($r['ok']&&$r['containers']===$case[1]&&$r['tokens']===$case[2],'count '. $case[0]);} +check(preflight_budget('[[],{}]',3,0)['ok'],'exact container boundary'); +check(!preflight_budget('[[],{}]',2,0)['ok'],'container +1 rejected'); +check(preflight_budget('[0,1,"x"]',1,3)['ok'],'exact token boundary'); +check(!preflight_budget('[0,1,"x"]',1,2)['ok'],'token +1 rejected'); +foreach(array('[','[1,]','{"x":}', '["unterminated') as $bad){$r=preflight_budget($bad);json_decode($bad,false,16);check(!$r['ok'] || json_last_error()!==JSON_ERROR_NONE,'invalid JSON rejected by final decoder');} +echo "OK: $n scanner assertions passed.\n";