42 lines
876 B
PHP
42 lines
876 B
PHP
--TEST--
|
|
Test for `Arma\Complex`.
|
|
--SKIPIF--
|
|
<?php
|
|
require_once 'includes/loaded.php';
|
|
require_once 'includes/supports.php';
|
|
if (is_php_arma_loaded()) {
|
|
supports_operator_overloading();
|
|
}
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
require_once 'includes/assert.php';
|
|
|
|
use function Arma\j;
|
|
|
|
$foo = 1.2 + j(1.7);
|
|
$bar = 2.3 + j(2.6);
|
|
|
|
batch_assert('operator overloading of Arma\\Complex',
|
|
[$foo->add($bar), $foo + $bar],
|
|
[$foo->sub($bar), $foo - $bar],
|
|
[$foo->neg(), -$foo],
|
|
[$foo->mul($bar), $foo * $bar],
|
|
[$foo->div($bar), $foo / $bar],
|
|
[$foo->pow($bar), $foo ** $bar],
|
|
[$foo->conj(), ~$foo]
|
|
);
|
|
|
|
$foo1 = $foo->add($bar);
|
|
$bar1 = $bar->pow($foo1);
|
|
$foo2 = $foo1->sub($bar1);
|
|
$bar2 = $bar1->div($foo2);
|
|
$foo3 = $foo2->mul($bar2);
|
|
$foo *= $bar /= $foo -= $bar **= $foo += $bar;
|
|
|
|
batch_assert('operator overloading of Arma\\Complex', [$foo3, $foo]);
|
|
|
|
?>
|
|
--EXPECT--
|