From 7ccdd3add90464585b524b702c8a0aa8a1aa8f11 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 7 Jul 2026 13:46:35 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0AOT=E5=A4=9A=E9=A1=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E9=AA=8C=E8=AF=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../array-diff-key-strict-dominators.phpt | 31 +++++++ .../array/array-unique-values-reindex.phpt | 31 +++++++ tests/aot/basic/repeatable-argv-parser.phpt | 61 ++++++++++++++ .../dynamic-subclass-interface-check.phpt | 37 +++++++++ .../assign-coalesce-instanceof-rhs.phpt | 47 +++++++++++ .../control_flow/match-true-instanceof.phpt | 31 +++++++ .../functions/array-unique-count-strict.phpt | 23 ++++++ .../array-accessible-countable-iterable.phpt | 81 +++++++++++++++++++ 8 files changed, 342 insertions(+) create mode 100644 tests/aot/array/array-diff-key-strict-dominators.phpt create mode 100644 tests/aot/array/array-unique-values-reindex.phpt create mode 100644 tests/aot/basic/repeatable-argv-parser.phpt create mode 100644 tests/aot/class/dynamic-subclass-interface-check.phpt create mode 100644 tests/aot/coalesce/assign-coalesce-instanceof-rhs.phpt create mode 100644 tests/aot/control_flow/match-true-instanceof.phpt create mode 100644 tests/aot/functions/array-unique-count-strict.phpt create mode 100644 tests/aot/stdlib/array-accessible-countable-iterable.phpt diff --git a/tests/aot/array/array-diff-key-strict-dominators.phpt b/tests/aot/array/array-diff-key-strict-dominators.phpt new file mode 100644 index 00000000..0b2c7aaf --- /dev/null +++ b/tests/aot/array/array-diff-key-strict-dominators.phpt @@ -0,0 +1,31 @@ +--TEST-- +array_keys after array_diff_key with integer block ids +--FILE-- + true])); +} + +function main(): void +{ + $dominators = [ + 0 => [0 => true], + 1 => [0 => true, 1 => true], + 2 => [0 => true, 1 => true, 2 => true], + ]; + + var_dump(strict_dominators($dominators, 0)); + var_dump(strict_dominators($dominators, 2)); +} +?> +--EXPECT-- +array(0) { +} +array(2) { + [0]=> + int(0) + [1]=> + int(1) +} diff --git a/tests/aot/array/array-unique-values-reindex.phpt b/tests/aot/array/array-unique-values-reindex.phpt new file mode 100644 index 00000000..b7fcb6c7 --- /dev/null +++ b/tests/aot/array/array-unique-values-reindex.phpt @@ -0,0 +1,31 @@ +--TEST-- +array_values reindexes array_unique result +--FILE-- + 'x', 5 => 'x', 9 => 'y'])); +} +?> +--EXPECT-- +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "c" +} +array(2) { + [0]=> + string(1) "x" + [1]=> + string(1) "y" +} diff --git a/tests/aot/basic/repeatable-argv-parser.phpt b/tests/aot/basic/repeatable-argv-parser.phpt new file mode 100644 index 00000000..17a93c12 --- /dev/null +++ b/tests/aot/basic/repeatable-argv-parser.phpt @@ -0,0 +1,61 @@ +--TEST-- +repeatable argv parser with separated equals and compact short flags +--FILE-- + +--EXPECT-- +array(3) { + [0]=> + string(7) "include" + [1]=> + string(12) "/opt/include" + [2]=> + string(8) "relative" +} diff --git a/tests/aot/class/dynamic-subclass-interface-check.phpt b/tests/aot/class/dynamic-subclass-interface-check.phpt new file mode 100644 index 00000000..ba13ca7c --- /dev/null +++ b/tests/aot/class/dynamic-subclass-interface-check.phpt @@ -0,0 +1,37 @@ +--TEST-- +dynamic is_subclass_of and class_implements checks +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) diff --git a/tests/aot/coalesce/assign-coalesce-instanceof-rhs.phpt b/tests/aot/coalesce/assign-coalesce-instanceof-rhs.phpt new file mode 100644 index 00000000..12007b76 --- /dev/null +++ b/tests/aot/coalesce/assign-coalesce-instanceof-rhs.phpt @@ -0,0 +1,47 @@ +--TEST-- +null coalescing assignment with instanceof boolean expression rhs +--FILE-- +enabled(); +} + +function main(): void +{ + $options = []; + ensure_option($options, new CoalescePlatform()); + var_dump($options); + + ensure_option($options, new CoalescePlatform()); + var_dump($options); + + $options = []; + ensure_option($options, new stdClass()); + var_dump($options); +} +?> +--EXPECT-- +enabled +array(1) { + ["is_zts"]=> + bool(true) +} +array(1) { + ["is_zts"]=> + bool(true) +} +array(1) { + ["is_zts"]=> + bool(false) +} diff --git a/tests/aot/control_flow/match-true-instanceof.phpt b/tests/aot/control_flow/match-true-instanceof.phpt new file mode 100644 index 00000000..51e7ee6f --- /dev/null +++ b/tests/aot/control_flow/match-true-instanceof.phpt @@ -0,0 +1,31 @@ +--TEST-- +match true with instanceof conditions +--FILE-- + 'child', + $value instanceof MatchTrueBase => 'base', + is_string($value) => 'string:' . $value, + default => 'other', + }; +} + +function main(): void +{ + var_dump(describe_value(new MatchTrueChild())); + var_dump(describe_value(new MatchTrueBase())); + var_dump(describe_value('x')); + var_dump(describe_value(42)); +} +?> +--EXPECT-- +string(5) "child" +string(4) "base" +string(8) "string:x" +string(5) "other" diff --git a/tests/aot/functions/array-unique-count-strict.phpt b/tests/aot/functions/array-unique-count-strict.phpt new file mode 100644 index 00000000..1bedea6f --- /dev/null +++ b/tests/aot/functions/array-unique-count-strict.phpt @@ -0,0 +1,23 @@ +--TEST-- +count array_unique result for duplicate detection +--FILE-- + +--EXPECT-- +int(2) +int(2) +int(0) diff --git a/tests/aot/stdlib/array-accessible-countable-iterable.phpt b/tests/aot/stdlib/array-accessible-countable-iterable.phpt new file mode 100644 index 00000000..905b2f46 --- /dev/null +++ b/tests/aot/stdlib/array-accessible-countable-iterable.phpt @@ -0,0 +1,81 @@ +--TEST-- +array or interface object checks for accessible countable iterable values +--FILE-- + 1, 'b' => 2]; + + public function offsetExists(mixed $offset): bool + { + return isset($this->items[$offset]); + } + + public function offsetGet(mixed $offset): mixed + { + return $this->items[$offset]; + } + + public function offsetSet(mixed $offset, mixed $value): void + { + $this->items[$offset] = $value; + } + + public function offsetUnset(mixed $offset): void + { + unset($this->items[$offset]); + } + + public function count(): int + { + return count($this->items); + } + + public function getIterator(): Traversable + { + return new ArrayIterator($this->items); + } +} + +function check_value(mixed $value): array +{ + return [ + is_array($value) || $value instanceof ArrayAccess, + is_array($value) || $value instanceof Countable, + is_array($value) || $value instanceof Traversable, + ]; +} + +function main(): void +{ + var_dump(check_value(['x'])); + var_dump(check_value(new AccessCountIterator())); + var_dump(check_value(new stdClass())); +} +?> +--EXPECT-- +array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + bool(true) +} +array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + bool(true) +} +array(3) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + bool(false) +}