alsk/tests/edsl/op/loop.cpp

51 lines
1.3 KiB
C++
Raw Permalink Normal View History

2021-05-10 16:14:13 +00:00
#include <catch.hpp>
#include <alsk/alsk.h>
using namespace alsk::edsl;
struct Do { void operator()() { std::puts("Do"); } };
TEST_CASE("edsl::Loop") {
auto aDo = makeOperand<Do>();
auto e0 = loop(aDo);
using E0 = decltype(e0);
using S0 = alsk::S<alsk::Loop, Do>;
using L0 = alsk::L<alsk::Loop, void(), void()>;
auto e1 = seq(5*aDo);
using E1 = decltype(e1);
using S1 = alsk::S<alsk::Loop, Do>;
using L1 = alsk::L<alsk::Loop, void(), void()>;
auto e2 = &(aDo*3);
using E2 = decltype(e2);
using S2 = alsk::S<alsk::Loop, Do>;
using L2 = alsk::L<alsk::Loop, void(), void()>;
SECTION("Construction") {
REQUIRE(std::is_same<E0::Struct, S0>{});
REQUIRE(std::is_same<E0::Links, L0>{});
REQUIRE(std::is_same<E0::Signature, void()>{});
REQUIRE(std::is_same<E1::Struct, S1>{});
REQUIRE(std::is_same<E1::Links, L1>{});
REQUIRE(std::is_same<E1::Signature, void()>{});
REQUIRE(std::is_same<E2::Struct, S2>{});
REQUIRE(std::is_same<E2::Links, L2>{});
REQUIRE(std::is_same<E2::Signature, void()>{});
}
SECTION("Setup") {
auto f0 = implement<alsk::exec::Sequential>(e0);
REQUIRE(f0.skeleton.n == 0);
auto f1 = implement<alsk::exec::Sequential>(e1);
REQUIRE(f1.skeleton.n == 5);
auto f2 = implement<alsk::exec::Sequential>(e2);
REQUIRE(f2.skeleton.n == 3);
}
}