78 lines
2.2 KiB
PHP
78 lines
2.2 KiB
PHP
<?php
|
|
|
|
// require_once(DIR_ALVEOLATA . '/definitions.php');
|
|
require_once(DIR_ALVEOLATA . '/structures/list/functions.php');
|
|
// require_once(DIR_ALVEOLATA . '/structures/list/wrapper-class.php');
|
|
|
|
|
|
\alveolata\test\add(
|
|
[
|
|
'name' => 'alveolata',
|
|
'sections' => [
|
|
[
|
|
'name' => 'structures',
|
|
'sections' => [
|
|
[
|
|
'name' => 'list',
|
|
'sections' => [
|
|
[
|
|
'name' => 'map',
|
|
'cases' => [
|
|
[
|
|
'name' => 'positive',
|
|
'procedure' => function ($assert) {
|
|
$subject = \alveolata\structures\list_make([2,3,5,7]);
|
|
$result_actual = \alveolata\structures\list_map($subject, function ($x) {return ($x * 2);});
|
|
$result_expected = \alveolata\structures\list_make([4,6,10,14]);
|
|
$assert->equal(
|
|
\alveolata\structures\list_collate(
|
|
function ($x, $y) {return ($x === $y);},
|
|
$result_actual,
|
|
$result_expected
|
|
),
|
|
true
|
|
);
|
|
}
|
|
],
|
|
[
|
|
'name' => 'negative_length',
|
|
'procedure' => function ($assert) {
|
|
$subject = \alveolata\structures\list_make([2,3,5,7]);
|
|
$result_actual = \alveolata\structures\list_map($subject, function ($x) {return ($x * 2);});
|
|
$result_expected = \alveolata\structures\list_make([4,6,10]);
|
|
$assert->equal(
|
|
\alveolata\structures\list_collate(
|
|
function ($x, $y) {return ($x === $y);},
|
|
$result_actual,
|
|
$result_expected
|
|
),
|
|
false
|
|
);
|
|
}
|
|
],
|
|
[
|
|
'name' => 'negative_element',
|
|
'procedure' => function ($assert) {
|
|
$subject = \alveolata\structures\list_make([2,3,5,7]);
|
|
$result_actual = \alveolata\structures\list_map($subject, function ($x) {return ($x * 2);});
|
|
$result_expected = \alveolata\structures\list_make([4,6,9,14]);
|
|
$assert->equal(
|
|
\alveolata\structures\list_collate(
|
|
function ($x, $y) {return ($x === $y);},
|
|
$result_actual,
|
|
$result_expected
|
|
),
|
|
false
|
|
);
|
|
}
|
|
],
|
|
]
|
|
],
|
|
]
|
|
],
|
|
]
|
|
]
|
|
]
|
|
]
|
|
);
|
|
|