<?php
$root=$argv[1];require $root.'/thinkphp/base.php';\think\Loader::addNamespace('app',$root.'/application/');
$checks=0;$fails=[];
if(!method_exists(\app\common\service\DishFixedFloatWrite::class,'physicalRow')){echo 'Missing physical read contract',PHP_EOL;exit(1);}
foreach([true,false]as$dm)foreach([1.24,0.02,1.0,2.67,1000000.0,-1.24]as$v){$raw=unpack('g',pack('g',$v))[1];$row=['price'=>$raw,'other'=>$raw,'nullable'=>null,'string'=>'1.240000009'];$actual=\app\common\service\DishFixedFloatWrite::physicalRow($row,['price'],$dm);$expected=$row;if($dm)$expected['price']=$v;$checks++;if($actual!==$expected)$fails[]='physical-read';}
$row=['price'=>1.2350000143051147];$checks++;if(\app\common\service\DishFixedFloatWrite::physicalRow($row,['price'],true)!==$row)$fails[]='unquantized-legacy-not-hidden';
echo json_encode(['checks'=>$checks,'failures'=>$fails]),PHP_EOL;exit($fails?1:0);
