alsk/tests/edsl/op/farmsel.cpp

53 lines
1.6 KiB
C++
Raw Normal View History

2021-05-10 16:14:13 +00:00
#include <catch.hpp>
#include <alsk/alsk.h>
using namespace alsk::edsl;
struct Generate { int operator()() { return 0; } };
struct Select { int operator()(int a, int b) { return std::max(a, b); } };
TEST_CASE("edsl::FarmSel") {
auto generate = makeOperand<int(), Generate>();
auto select = makeOperand<int(int, int), Select>();
auto e0 = (10 * generate) ->* select;
using E0 = decltype(e0);
using S0 = alsk::S<alsk::FarmSel, Generate, Select>;
using L0 = alsk::L<alsk::FarmSel, int(), int(), int(int, int)>;
auto e1 = link<void(int)>(*generate) ->* select;
using E1 = decltype(e1);
using S1 = alsk::S<alsk::FarmSel, Generate, Select>;
using L1 = alsk::L<alsk::FarmSel, int(int), int(), int(int, int)>;
auto e2 = farm(generate).select(select);
using E2 = decltype(e2);
using S2 = alsk::S<alsk::FarmSel, Generate, Select>;
using L2 = alsk::L<alsk::FarmSel, int(), int(), int(int, int)>;
SECTION("Construction") {
REQUIRE(std::is_same<E0::Struct, S0>{});
REQUIRE(std::is_same<E0::Links, L0>{});
REQUIRE(std::is_same<E0::Signature, int()>{});
REQUIRE(std::is_same<E1::Struct, S1>{});
REQUIRE(std::is_same<E1::Links, L1>{});
REQUIRE(std::is_same<E1::Signature, int(int)>{});
REQUIRE(std::is_same<E2::Struct, S2>{});
REQUIRE(std::is_same<E2::Links, L2>{});
REQUIRE(std::is_same<E2::Signature, int()>{});
}
SECTION("Setup") {
auto f0 = implement<alsk::exec::DynamicPool>(e0);
REQUIRE(f0.skeleton.n == 10);
auto f1 = implement<alsk::exec::DynamicPool>(e1);
REQUIRE(f1.skeleton.n == 0);
auto f2 = implement<alsk::exec::DynamicPool>(e2);
REQUIRE(f2.skeleton.n == 0);
}
}