Skip to content

Commit

Permalink
Rename select_signal to 'select'.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadden committed Jul 6, 2018
1 parent fde401f commit 922f856
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/alia/signals/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ operator&&(A const& a, B const& b)
}

// This is the equivalent of the ternary operator for signals.
// select_signal(condition, t, f), where condition, t and f are signals,
// select(condition, t, f), where condition, t and f are signals,
// yields t if condition's value is true and f if condition's value is false.
// Note that this is a normal function call, so, unlike an if statement or the
// ternary operator, both t and f are fully evaluated. However, they are only
Expand Down Expand Up @@ -227,7 +227,7 @@ struct signal_mux : signal<
};
template<class Condition, class T, class F>
signal_mux<Condition, T, F>
select_signal(Condition const& condition, T const& t, F const& f)
select(Condition const& condition, T const& t, F const& f)
{
return signal_mux<Condition, T, F>(condition, t, f);
}
Expand Down
24 changes: 12 additions & 12 deletions unit_tests/signals/operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ TEST_CASE("signal ||", "[signals]")
!= (value(true) || value(false)).value_id());
}

TEST_CASE("select_signal", "[signals]")
TEST_CASE("signal select", "[signals]")
{
using namespace alia;

bool condition = false;
auto s = select_signal(direct(condition), value(1), value(2));
auto s = select(direct(condition), value(1), value(2));

typedef decltype(s) signal_t;
REQUIRE(signal_can_read<signal_t>::value);
Expand All @@ -123,12 +123,12 @@ TEST_CASE("select_signal", "[signals]")
REQUIRE(captured_id.get() != s.value_id());
}

TEST_CASE("select_signal with different directions", "[signals]")
TEST_CASE("select with different directions", "[signals]")
{
using namespace alia;

bool condition = false;
auto s = select_signal(direct(condition), empty<int>(), value(2));
auto s = select(direct(condition), empty<int>(), value(2));

typedef decltype(s) signal_t;
REQUIRE(signal_can_read<signal_t>::value);
Expand All @@ -140,41 +140,41 @@ TEST_CASE("select_signal with different directions", "[signals]")
REQUIRE(!signal_is_readable(s));
}

TEST_CASE("select_signal value ID", "[signals]")
TEST_CASE("select value ID", "[signals]")
{
// Test that select_signal's ID changes when the condition changes, even
// if both of its input signals are producing the same value ID.
// Test that select's ID changes when the condition changes, even if both of
// its input signals are producing the same value ID.

using namespace alia;

bool condition = false;
auto s = select_signal(direct(condition), value(2), value(2));
auto s = select(direct(condition), value(2), value(2));

owned_id captured_id;
captured_id.store(s.value_id());
condition = true;
REQUIRE(captured_id.get() != s.value_id());
}

TEST_CASE("select_signal with unreadable condition", "[signals]")
TEST_CASE("select with unreadable condition", "[signals]")
{
using namespace alia;

int x = 0, y = 1;
auto s = select_signal(empty<bool>(), direct(x), direct(y));
auto s = select(empty<bool>(), direct(x), direct(y));
REQUIRE(!signal_is_readable(s));
REQUIRE(s.value_id() == no_id);
REQUIRE(!signal_is_writable(s));
}

TEST_CASE("writable select_signal", "[signals]")
TEST_CASE("writable select", "[signals]")
{
using namespace alia;

bool condition = false;
int x = 1;
int y = 2;
auto s = select_signal(direct(condition), direct(x), direct(y));
auto s = select(direct(condition), direct(x), direct(y));

typedef decltype(s) signal_t;
REQUIRE(signal_can_read<signal_t>::value);
Expand Down

0 comments on commit 922f856

Please sign in to comment.