39 lines
590 B
PHP
39 lines
590 B
PHP
--TEST--
|
|
Test for methods `forEach()`, `transform()`, `replace()`.
|
|
--SKIPIF--
|
|
<?php
|
|
require_once 'includes/loaded.php';
|
|
is_php_arma_loaded();
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
$mat = Arma\IMat::fromString('1 2; 3 4');
|
|
$mat->rawPrint();
|
|
$mat->forEach(function (Arma\MapVal $elem) {
|
|
$elem_val = $elem->val();
|
|
echo $elem_val;
|
|
$elem->setTo($elem_val + 4);
|
|
});
|
|
echo PHP_EOL;
|
|
$mat->rawPrint();
|
|
$mat->transform(function (int $elem) {
|
|
return $elem + 4;
|
|
});
|
|
$mat->rawPrint();
|
|
$mat->replace(10, -1);
|
|
$mat->replace(11, -2);
|
|
$mat->rawPrint();
|
|
|
|
?>
|
|
--EXPECT--
|
|
1 2
|
|
3 4
|
|
1324
|
|
5 6
|
|
7 8
|
|
9 10
|
|
11 12
|
|
9 -1
|
|
-2 12
|