1
0
forked from Alepha/Alepha

Function Composition helpers

This commit is contained in:
2025-09-07 03:44:38 -04:00
parent 4116db0103
commit 00908187bd
7 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,48 @@
static_assert( __cplusplus >= 2023'02 );
#include <Alepha/Functional/composition.h>
#include <Alepha/Testing/test.h>
#include <Alepha/Utility/enroll.h>
namespace
{
using namespace Alepha::Testing::exports;
auto init= Alepha::Utility::enroll <=[]
{
"smoke test"_test <=[]( Environment test )
{
using namespace Alepha::Functional::exports::composition_m;
auto i= ident * ident;
auto add_two= []( const int x )
{
return x + 2;
};
auto mult_two= []( const int x ) { return x * 2; };
auto add_two_then_mult_two= mult_two * add_two;
test.expect( add_two_then_mult_two( 1 ) == 6 );
};
"compose test"_test <=[]( Environment test )
{
using namespace Alepha::Functional::exports::composition_m;
auto add= []( const int x, const int y )
{
return x + y;
};
auto mult3= []( const int x ) { return x * 3; };
test.expect( ( add >> mult3 )( 2, 1 ) == 9 );
};
};
}

View File

@ -0,0 +1 @@
unit_test( 0 )