Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move execute(initializer_list) to fizzy::test #657

Merged
merged 1 commit into from
Nov 20, 2020
Merged

Conversation

chfast
Copy link
Collaborator

@chfast chfast commented Nov 20, 2020

No description provided.

@@ -38,11 +38,4 @@ constexpr ExecutionResult Trap{false};

// Execute a function on an instance.
ExecutionResult execute(Instance& instance, FuncIdx func_idx, const Value* args, int depth = 0);

inline ExecutionResult execute(
Instance& instance, FuncIdx func_idx, std::initializer_list<Value> args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move this though?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The std::initializer_list<Value> cannot be used in public API like that. This is not what it is designed for. We can use std::span instead.
  2. I prefer to change it to std::initializer_list<TypedValue> later instead of having a ton of overloads spread accross many places.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The std::initializer_list cannot be used in public API like that. This is not what it is designed for. We can use std::span instead.

Not arguing against, but can you explain the reason for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This usage is probably fine, but there are some doubts about the lifetime of the {} object. The std::initializer_list is to provide fancy syntax to containers. Somehow in C++20 had been decided that std::span cannot reference std::initializer_list.

In practice this is mostly useful in cases when you want to provide some fixed number of arguments, i.e. mostly tests and examples. None of the other tools need it.

@codecov
Copy link

codecov bot commented Nov 20, 2020

Codecov Report

Merging #657 (892b3ba) into master (5a17546) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #657   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files          69       69           
  Lines        9724     9724           
=======================================
  Hits         9567     9567           
  Misses        157      157           
Flag Coverage Δ
spectests 91.46% <ø> (-0.02%) ⬇️
unittests 98.38% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/fizzy/execute.hpp 100.00% <ø> (ø)
test/unittests/api_test.cpp 100.00% <ø> (ø)
test/unittests/end_to_end_test.cpp 100.00% <ø> (ø)
...ittests/execute_floating_point_conversion_test.cpp 99.28% <ø> (ø)
test/unittests/execute_floating_point_test.cpp 99.69% <ø> (ø)
test/utils/execute_helpers.hpp 100.00% <100.00%> (ø)

@chfast chfast merged commit 3f91da9 into master Nov 20, 2020
@chfast chfast deleted the test_execution_helpers branch November 20, 2020 21:18
@gumb0 gumb0 mentioned this pull request Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants