diff --git a/tests/aot/bigint/divmod.phpt b/tests/aot/bigint/divmod.phpt new file mode 100644 index 00000000..7e59b364 --- /dev/null +++ b/tests/aot/bigint/divmod.phpt @@ -0,0 +1,35 @@ +--TEST-- +BigInt: divmod +--FILE-- +divmod($b); + var_dump(std::bigInt($r[0])->toString()); + var_dump(std::bigInt($r[1])->toString()); + + $c = std::bigInt(100); + $d = std::bigInt(7); + $r2 = $c->divmod($d); + var_dump(std::bigInt($r2[0])->toString()); + var_dump(std::bigInt($r2[1])->toString()); + + // negative dividend + $e = std::bigInt(-10); + $f = std::bigInt(3); + $r3 = $e->divmod($f); + var_dump(std::bigInt($r3[0])->toString()); + var_dump(std::bigInt($r3[1])->toString()); +} +?> +--EXPECT-- +string(1) "3" +string(1) "1" +string(2) "14" +string(1) "2" +string(2) "-3" +string(2) "-1" diff --git a/tests/aot/bigint/gcd.phpt b/tests/aot/bigint/gcd.phpt new file mode 100644 index 00000000..4d178146 --- /dev/null +++ b/tests/aot/bigint/gcd.phpt @@ -0,0 +1,29 @@ +--TEST-- +BigInt: gcd +--FILE-- +gcd($b)->toString(); echo "\n"; + + $c = std::bigInt(100); + $d = std::bigInt(25); + echo $c->gcd($d)->toString(); echo "\n"; + + $e = std::bigInt(17); + $f = std::bigInt(13); + echo $e->gcd($f)->toString(); echo "\n"; + + // gcd with Int argument + echo $a->gcd(4)->toString(); echo "\n"; +} +?> +--EXPECT-- +4 +25 +1 +4 diff --git a/tests/aot/bigint/powmod.phpt b/tests/aot/bigint/powmod.phpt new file mode 100644 index 00000000..caa326db --- /dev/null +++ b/tests/aot/bigint/powmod.phpt @@ -0,0 +1,28 @@ +--TEST-- +BigInt: powmod +--FILE-- +powmod(std::bigInt(10), std::bigInt(1000)); + echo $r->toString(); echo "\n"; + + // 3^20 mod 100 = 3486784401 mod 100 = 1 + $b = std::bigInt(3); + $r2 = $b->powmod(std::bigInt(20), std::bigInt(100)); + echo $r2->toString(); echo "\n"; + + // 5^3 mod 13 = 125 mod 13 = 8 + $c = std::bigInt(5); + $r3 = $c->powmod(std::bigInt(3), std::bigInt(13)); + echo $r3->toString(); echo "\n"; +} +?> +--EXPECT-- +24 +1 +8 diff --git a/tests/aot/bigint/sqrt.phpt b/tests/aot/bigint/sqrt.phpt new file mode 100644 index 00000000..5a6c27fa --- /dev/null +++ b/tests/aot/bigint/sqrt.phpt @@ -0,0 +1,32 @@ +--TEST-- +BigInt: sqrt +--FILE-- +sqrt()->toString(); echo "\n"; + + $b = std::bigInt(1); + echo $b->sqrt()->toString(); echo "\n"; + + $c = std::bigInt(100); + echo $c->sqrt()->toString(); echo "\n"; + + // Integer sqrt: sqrt(2) = 1 + $d = std::bigInt(2); + echo $d->sqrt()->toString(); echo "\n"; + + // Large perfect square: 10^20, sqrt = 10^10 + $e = std::bigInt("100000000000000000000"); + echo $e->sqrt()->toString(); echo "\n"; +} +?> +--EXPECT-- +0 +1 +10 +1 +10000000000 diff --git a/tests/aot/bigint/toInt_toFloat.phpt b/tests/aot/bigint/toInt_toFloat.phpt new file mode 100644 index 00000000..6dc2e37d --- /dev/null +++ b/tests/aot/bigint/toInt_toFloat.phpt @@ -0,0 +1,20 @@ +--TEST-- +BigInt: toInt / toFloat +--FILE-- +toInt()); + var_dump($a->toFloat()); + + $b = std::bigInt(-100); + var_dump($b->toInt()); +} +?> +--EXPECT-- +int(42) +float(42) +int(-100) diff --git a/tests/aot/decimal/ceil.phpt b/tests/aot/decimal/ceil.phpt new file mode 100644 index 00000000..302b2a7e --- /dev/null +++ b/tests/aot/decimal/ceil.phpt @@ -0,0 +1,26 @@ +--TEST-- +Decimal: ceil +--FILE-- +ceil()->toString()); + + $b = std::decimal("-3.2"); + var_dump($b->ceil()->toString()); + + $c = std::decimal("5.0"); + var_dump($c->ceil()->toString()); + + $d = std::decimal("0.1"); + var_dump($d->ceil()->toString()); +} +?> +--EXPECT-- +string(1) "4" +string(2) "-3" +string(1) "5" +string(1) "1" diff --git a/tests/aot/decimal/divmod.phpt b/tests/aot/decimal/divmod.phpt new file mode 100644 index 00000000..7d1a520b --- /dev/null +++ b/tests/aot/decimal/divmod.phpt @@ -0,0 +1,26 @@ +--TEST-- +Decimal: divmod +--FILE-- +divmod($b); + var_dump(std::decimal($r[0])->toString()); + var_dump(std::decimal($r[1])->toString()); + + $c = std::decimal("17.5"); + $d = std::decimal("5.0"); + $r2 = $c->divmod($d); + var_dump(std::decimal($r2[0])->toString()); + var_dump(std::decimal($r2[1])->toString()); +} +?> +--EXPECT-- +string(1) "3" +string(1) "1" +string(1) "3" +string(3) "2.5" diff --git a/tests/aot/decimal/floor.phpt b/tests/aot/decimal/floor.phpt new file mode 100644 index 00000000..97b38fc4 --- /dev/null +++ b/tests/aot/decimal/floor.phpt @@ -0,0 +1,26 @@ +--TEST-- +Decimal: floor +--FILE-- +floor()->toString()); + + $b = std::decimal("-3.7"); + var_dump($b->floor()->toString()); + + $c = std::decimal("5.0"); + var_dump($c->floor()->toString()); + + $d = std::decimal("0.1"); + var_dump($d->floor()->toString()); +} +?> +--EXPECT-- +string(1) "3" +string(2) "-4" +string(1) "5" +string(1) "0" diff --git a/tests/aot/decimal/pow.phpt b/tests/aot/decimal/pow.phpt new file mode 100644 index 00000000..5bf64ceb --- /dev/null +++ b/tests/aot/decimal/pow.phpt @@ -0,0 +1,22 @@ +--TEST-- +Decimal: pow +--FILE-- +pow(std::decimal("3"))->toString()); + + $b = std::decimal("10"); + var_dump($b->pow(std::decimal("2"))->toString()); + + $c = std::decimal("3"); + var_dump($c->pow(std::decimal("3"))->toString()); +} +?> +--EXPECT-- +string(1) "8" +string(3) "100" +string(2) "27" diff --git a/tests/aot/decimal/powmod.phpt b/tests/aot/decimal/powmod.phpt new file mode 100644 index 00000000..a6369d0a --- /dev/null +++ b/tests/aot/decimal/powmod.phpt @@ -0,0 +1,22 @@ +--TEST-- +Decimal: powmod +--FILE-- +powmod(std::decimal("10"), std::decimal("1000")); + var_dump($r->toString()); + + // 3^4 mod 5 = 81 mod 5 = 1 + $b = std::decimal("3"); + $r2 = $b->powmod(std::decimal("4"), std::decimal("5")); + var_dump($r2->toString()); +} +?> +--EXPECT-- +string(2) "24" +string(1) "1" diff --git a/tests/aot/decimal/round.phpt b/tests/aot/decimal/round.phpt new file mode 100644 index 00000000..ba4ccc61 --- /dev/null +++ b/tests/aot/decimal/round.phpt @@ -0,0 +1,32 @@ +--TEST-- +Decimal: round +--FILE-- +round()->toString()); + + $b = std::decimal("3.5"); + var_dump($b->round()->toString()); + + $c = std::decimal("-3.5"); + var_dump($c->round()->toString()); + + // round with precision + $d = std::decimal("3.14159"); + var_dump($d->round(2)->toString()); + + $e = std::decimal("2.71828"); + var_dump($e->round(3)->toString()); +} +?> +--EXPECT-- +string(1) "3" +string(1) "4" +string(2) "-4" +string(4) "3.14" +string(5) "2.718" diff --git a/tests/aot/decimal/sqrt.phpt b/tests/aot/decimal/sqrt.phpt new file mode 100644 index 00000000..5e8c172c --- /dev/null +++ b/tests/aot/decimal/sqrt.phpt @@ -0,0 +1,26 @@ +--TEST-- +Decimal: sqrt +--FILE-- +sqrt()->toString()); + + $b = std::decimal("1"); + var_dump($b->sqrt()->toString()); + + $c = std::decimal("100"); + var_dump($c->sqrt()->toString()); + + $d = std::decimal("4"); + var_dump($d->sqrt()->toString()); +} +?> +--EXPECT-- +string(1) "0" +string(1) "1" +string(2) "10" +string(1) "2" diff --git a/tests/aot/decimal/toFloat.phpt b/tests/aot/decimal/toFloat.phpt new file mode 100644 index 00000000..70e3f548 --- /dev/null +++ b/tests/aot/decimal/toFloat.phpt @@ -0,0 +1,18 @@ +--TEST-- +Decimal: toFloat +--FILE-- +toFloat()); + + $b = std::decimal("100.5"); + var_dump($b->toFloat()); +} +?> +--EXPECT-- +float(3.14) +float(100.5)