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

Introduce TypedValue to fizzy::test #658

Merged
merged 4 commits into from
Nov 23, 2020
Merged

Introduce TypedValue to fizzy::test #658

merged 4 commits into from
Nov 23, 2020

Conversation

chfast
Copy link
Collaborator

@chfast chfast commented Nov 20, 2020

No description provided.

@codecov
Copy link

codecov bot commented Nov 20, 2020

Codecov Report

Merging #658 (ba84730) into master (3f91da9) will increase coverage by 0.00%.
The diff coverage is 93.51%.

@@           Coverage Diff           @@
##           master     #658   +/-   ##
=======================================
  Coverage   98.38%   98.39%           
=======================================
  Files          69       71    +2     
  Lines        9724     9765   +41     
=======================================
+ Hits         9567     9608   +41     
  Misses        157      157           
Flag Coverage Δ
spectests 91.46% <ø> (ø)
unittests 98.39% <93.51%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
test/testfloat/testfloat.cpp 90.78% <88.88%> (-0.26%) ⬇️
test/unittests/typed_value_test.cpp 100.00% <100.00%> (ø)
test/utils/typed_value.hpp 100.00% <100.00%> (ø)

@chfast chfast force-pushed the typed_value branch 2 times, most recently from 997929e to cd75e9f Compare November 20, 2020 23:01
@chfast chfast marked this pull request as ready for review November 21, 2020 10:34
@chfast chfast requested a review from gumb0 November 21, 2020 10:34
/// No validation is possible, so the correctness is on the user only.
constexpr TypedValue(ValType ty, Value v) noexcept : value{v}, type{ty} {}

constexpr TypedValue(int32_t v) noexcept : TypedValue{ValType::i32, v} {}
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 is in my options minimal set of constructors. Problem here is that on macOS uint64_t is defined differently than on Linux. On macOS the literals of long type are ambiguous, e.g. TypedValue(0x100000000) and it must be explicitly converted to uint64_t as TypedValue(0x100000000_u64).

static_assert(i32.type == ValType::i32);
static_assert(i32.value.i64 == uint32_t(-1));
EXPECT_EQ(i32.type, ValType::i32);
EXPECT_EQ(i32.value.i64, uint32_t(-1));
Copy link
Member

Choose a reason for hiding this comment

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

Why have both sattic_assert and EXPECT_EQ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Performing check in constexpr and non-contexpr context. This first one does not give code coverage.

constexpr TypedValue(float v) noexcept : TypedValue{ValType::f32, v} {}
constexpr TypedValue(double v) noexcept : TypedValue{ValType::f64, v} {}

constexpr operator Value() const noexcept { return value; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know any more. Some future PRs propose to drop it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was used ones, I dropped it. It is always easy to drop the type information by .value.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I was concerned that with it can be misleading e.g.

TypedValue v{1_u64};
if (v == Value{1_i32}) // true


TEST(typed_value, construct_contexpr)
{
constexpr TypedValue i32{int32_t{-1}};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: some value literals are defined with {} others with ().

Are _i32 literals merged yet? Can't we use them here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I got it, it was intentional, because somewhere conversion is happening.

@chfast chfast merged commit 5d443ee into master Nov 23, 2020
@chfast chfast deleted the typed_value branch November 23, 2020 14:59
@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.

3 participants