This repository has been archived on 2020-06-07. You can view files and clone it, but cannot push or open issues or pull requests.
php-armadillo/tests/013-foreach-transform-repla...

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