diff --git a/tests/aot/clone.phpt b/tests/aot/clone.phpt new file mode 100644 index 00000000..cbfef4c7 --- /dev/null +++ b/tests/aot/clone.phpt @@ -0,0 +1,35 @@ +--TEST-- +Clone keyword for object cloning +--FILE-- +value = $v; + } + + public function increment(): void { + $this->value++; + } +} + +function main() { + $original = new Counter(10); + $original->increment(); + + $cloned = clone $original; + $cloned->increment(); + $cloned->increment(); + + var_dump($original->value); + var_dump($cloned->value); + var_dump($original->value !== $cloned->value); +} + +?> +--EXPECT-- +int(11) +int(13) +bool(true) diff --git a/tests/aot/compound-assign.phpt b/tests/aot/compound-assign.phpt new file mode 100644 index 00000000..a500e8f8 --- /dev/null +++ b/tests/aot/compound-assign.phpt @@ -0,0 +1,62 @@ +--TEST-- +Compound assignment in expressions +--FILE-- +val += 5; + $obj->val *= 2; + $obj->val -= 3; + $obj->val %= 4; + var_dump($obj->val); + + // Chained assignments + $a = $b = $c = 10; + var_dump($a); + var_dump($b); + var_dump($c); + + // Reference assignment + $y = 2; + $z = &$y; + $y = 5; + var_dump($z); + + // Global variable with assignment + global $config; + $config = ["debug" => true]; + var_dump($config["debug"]); + + echo "done\n"; +} + +?> +--EXPECT-- +array(3) { + [0]=> + int(11) + [1]=> + int(6) + [2]=> + int(2) +} +int(3) +int(10) +int(10) +int(10) +int(5) +bool(true) +done diff --git a/tests/aot/exit-test.phpt b/tests/aot/exit-test.phpt new file mode 100644 index 00000000..7da48a43 --- /dev/null +++ b/tests/aot/exit-test.phpt @@ -0,0 +1,35 @@ +--TEST-- +exit/die language constructs +--FILE-- + 0) { + echo "should not reach here\n"; + } + echo "code is zero\n"; +} + +function processValue(mixed $val): string { + if (!is_string($val)) { + die("not a string"); + } + return "string: " . $val; +} + +function main() { + testExit(0); + + $result = processValue("hello"); + var_dump($result); + + $status = 42; + $x = $status == 0 ? 'zero' : 'non-zero'; + var_dump($x); +} + +?> +--EXPECT-- +code is zero +string(13) "string: hello" +string(8) "non-zero" diff --git a/tests/aot/nested-closures.phpt b/tests/aot/nested-closures.phpt new file mode 100644 index 00000000..beef46d1 --- /dev/null +++ b/tests/aot/nested-closures.phpt @@ -0,0 +1,56 @@ +--TEST-- +Nested closures and closure scope +--FILE-- + +--EXPECT-- +int(20) +int(15) +int(11) +string(11) "User: Alice" +int(6)