Updated code

This commit is contained in:
Dzejkobik007
2023-02-15 09:03:10 +01:00
parent 114ee6f42a
commit 3d420909e0

View File

@@ -1,4 +1,7 @@
<?php <?php
$EXECUTABLE = "php";
$datatypes = ["int", "string", "float"]; $datatypes = ["int", "string", "float"];
$testreturns = [ $testreturns = [
[10, 2, 10000], [10, 2, 10000],
@@ -6,27 +9,36 @@ $testreturns = [
[102, 0.0000002, 100, 00, 12315, 1231698] [102, 0.0000002, 100, 00, 12315, 1231698]
]; ];
$results = array();
$run = 0;
for ($i = 0; $i < sizeof($datatypes); $i++) { for ($i = 0; $i < sizeof($datatypes); $i++) {
for ($p = 0; $p < sizeof($datatypes); $p++) { for ($p = 0; $p < sizeof($datatypes); $p++) {
for ($k = 0; $k < sizeof($testreturns); $k++) { for ($k = 0; $k < sizeof($testreturns); $k++) {
if ($datatypes[$i] == "string"){ if ($datatypes[$i] == "string"){
$func = 'function test('.$datatypes[$i].' $input = "'.$testreturns[$i][$k].'"): '.$datatypes[$p].' { return $input; } try { return test(); } catch (Exception $e) { return "Exception";}'; $func = '<?php function test('.$datatypes[$i].' $input = "'.$testreturns[$i][$k].'"): '.$datatypes[$p].' { return $input; } echo test();';
} else { } else {
$func = 'function test('.$datatypes[$i].' $input = '.$testreturns[$i][$k].'): '.$datatypes[$p].' { return $input; } try { return test(); } catch (Exception $e) { return "Exception";}'; $func = '<?php function test('.$datatypes[$i].' $input = '.$testreturns[$i][$k].'): '.$datatypes[$p].' { return $input; } echo test();';
} }
var_dump(eval($func));
$file = fopen("test.php", "w");
fwrite($file, $func);
fclose($file);
//var_dump($func);
$results[$run]["input_datatype"] = var_export($datatypes[$i], true);
$results[$run]["input"] = var_export($testreturns[$i][$k], true);
$results[$run]["output_datatype"] = var_export($datatypes[$p], true);
$results[$run]["output"] = var_export(shell_exec($EXECUTABLE." -f test.php"), true);
$run++;
// echo $func; // echo $func;
} }
} }
} }
var_dump($results);
$file = fopen("results.csv", "w");
for($i = 0; $i < sizeof($results); $i++) {
try { fwrite($file, $results[$i]["input_datatype"].";".$results[$i]["input"].";".$results[$i]["output_datatype"].";".$results[$i]["output"]."\n");
} catch (Exception $e) {
// echo $e;
} }
fclose($file);