-
Notifications
You must be signed in to change notification settings - Fork 4
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
For cpp20, renaming tests for using for scoped enums #72
For cpp20, renaming tests for using for scoped enums #72
Conversation
@@ -20,7 +20,8 @@ void require_equal(char const *file, unsigned line, T expected, U actual) | |||
if (expected != actual) | |||
{ | |||
std::ostringstream message; | |||
message << file << '(' << line << "): error: expected " << expected << ", got " << actual; | |||
//message << file << '(' << line << "): error: expected " << expected << ", got " << actual; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I've build errors on Ubuntu 22.04.3 LTS with clion, needed to change thsese lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct fix is to provide a stream insertion operator for the scoped enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only place where enum class
is used is in RenameCpp11.cpp
and in all cases the enum is cast to an int before calling require_equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For your new tests cases to int
or move the enum to a namespace scope where a stream insertion operator can be defined would be the right fix instead of changing the entire require_equal
mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confused about this comment, on master
branch, when I build refactor-test-suite
, I get the errors below which states the lines that I've never changed:
.../RefactorTest/Require.h:23:65: error: call to function 'operator<<' that is neither visible in the template definition nor found by argument-dependent lookup
message << file << '(' << line << "): error: expected " << expected << ", got " << actual;
^
.../RefactorTest/RenameCpp20.cpp:73:9: note: in instantiation of function template specialization 'require_equal<std::strong_ordering, std::strong_ordering>' requested here
REQUIRE_EQUAL(std::strong_ordering::equal, x <=> x);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, OK... I thought I had added stream insertion operators for those... linux CI build is compiling without errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What version compiler are you using?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google says ubuntu 22.04.3 LTS is using gcc-11, but I can't reproduce your error on compiler explorer:
https://godbolt.org/z/36Y6vxeTn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Please update per my comments.
@@ -278,7 +278,7 @@ void f8() | |||
{ | |||
// #TEST#: R937 Rename local variable vals | |||
// #TEST#: R938 Rename use of one | |||
const int vals[3](one, 2, 3); | |||
const int vals[3]{one, 2, 3}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change these. The comment on line 273 explicitly says that this is initialization via parentheses.
RefactorTest/RenameCpp20.cpp
Outdated
void f11() | ||
{ | ||
//#TEST#: R1521 Rename E | ||
enum class E : uint8_t { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format
all source code changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, clang-format
is applied
RefactorTest/RenameCpp20.cpp
Outdated
|
||
struct F11 { | ||
using enum E; | ||
}f11Ins; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate declaration of struct and declaration of variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, separated
RefactorTest/RenameCpp20.cpp
Outdated
using enum E; | ||
}f11Ins; | ||
|
||
const auto& get_enumerator = [&]() -> auto { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd that you are taking a reference to a temporary. Not undefined behavior, but just odd.
results/CLionResults.md
Outdated
@@ -2102,6 +2102,10 @@ R1517 | | |||
R1518 | | |||
R1519 | | |||
R1520 | | |||
R1521 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to rebase on HEAD as I'm adding lots of tests recently. Easiest thing to do is to mark the tests as newly added and re-add them using the add-tests
tool as described in Contributing.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, rebased.
d5d6b10
to
fa691d2
Compare
void f11() | ||
{ | ||
//#GOINK#: ID Rename E | ||
enum class E : uint8_t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails to build when the enum is local to this function. I suspect that is because the anonymous class created for the lambda is emitted to the enclosing namespace scope and not as a local inside this function. If I move the enum to namespace scope, then it compiles. Please update your code to put the enum in the namespace scope to correct this build error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you haven't included a header to define uint8_t
and it's not important to this test, so just drop off the : uint8_t
base type and declare enum class E
//#GOINK#: ID Rename E | ||
enum class E : uint8_t | ||
{ | ||
//#GOINK#: ID Rename One |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put a space between the comment introducer (//
) and the test marker
@@ -20,7 +20,8 @@ void require_equal(char const *file, unsigned line, T expected, U actual) | |||
if (expected != actual) | |||
{ | |||
std::ostringstream message; | |||
message << file << '(' << line << "): error: expected " << expected << ", got " << actual; | |||
//message << file << '(' << line << "): error: expected " << expected << ", got " << actual; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change.
I've corrected the problems and merged your (amended by me) commit to master. |
Via this commit, I aimed to resolve the task
using for scoped enums
which is indicated on issue 58