Skip to content

Commit

Permalink
update some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jul 10, 2020
1 parent 33a7a9c commit 3301eac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Language: Cpp
Standard: c++17
Standard: Cpp11
BasedOnStyle: Chromium

AccessModifierOffset: -4
Expand Down
6 changes: 3 additions & 3 deletions test/utils/asserts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace fizzy
{
std::ostream& operator<<(std::ostream& os, execution_result result)
{
if (result.trapped)
if (result.trapped())
return os << "trapped";

os << "result(";
if (result.result.has_value())
os << *result.result;
if (result.has_value())
os << result.value();
os << ")";
return os;
}
Expand Down
6 changes: 3 additions & 3 deletions test/utils/asserts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

MATCHER(Traps, "") // NOLINT(readability-redundant-string-init)
{
return arg.trapped;
return arg.trapped();
}

MATCHER(Result, "empty result")
{
return !arg.trapped && !arg.result.has_value();
return !arg.trapped() && !arg.has_value();
}

MATCHER_P(Result, value, "") // NOLINT(readability-redundant-string-init)
{
return !arg.trapped && arg.result.has_value() && *arg.result == uint64_t(value);
return !arg.trapped() && arg.has_value() && arg.value() == uint64_t(value);
}

#define EXPECT_THROW_MESSAGE(stmt, ex_type, expected) \
Expand Down
9 changes: 5 additions & 4 deletions test/utils/fizzy_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fizzy::execution_result env_adler32(fizzy::Instance& instance, std::vector<uint6
{
assert(instance.memory != nullptr);
const auto ret = fizzy::test::adler32(bytes_view{*instance.memory}.substr(args[0], args[1]));
return {false, {ret}};
return {fizzy::execution_result::status::WithResult, ret};
}
} // namespace

Expand Down Expand Up @@ -133,8 +133,9 @@ std::optional<WasmEngine::FuncRef> FizzyEngine::find_function(
WasmEngine::Result FizzyEngine::execute(
WasmEngine::FuncRef func_ref, const std::vector<uint64_t>& args)
{
const auto [trapped, result] =
fizzy::execute(*m_instance, static_cast<uint32_t>(func_ref), args);
return {trapped, result};
const auto status = fizzy::execute(*m_instance, static_cast<uint32_t>(func_ref), args);
if (status.trapped())
return {true, 0};
return {false, status.value()};
}
} // namespace fizzy::test

0 comments on commit 3301eac

Please sign in to comment.