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

Adding Tests for edge cases #154

Merged
merged 25 commits into from
Oct 19, 2023

Conversation

Smit1603
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

Merging #154 (80b45f1) into main (ff578da) will increase coverage by 1.21%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #154      +/-   ##
==========================================
+ Coverage   64.64%   65.85%   +1.21%     
==========================================
  Files          17       17              
  Lines        4279     4326      +47     
==========================================
+ Hits         2766     2849      +83     
+ Misses       1513     1477      -36     
Files Coverage Δ
lib/Interpreter/CppInterOp.cpp 77.47% <ø> (+2.26%) ⬆️
unittests/CppInterOp/EnumReflectionTest.cpp 100.00% <100.00%> (ø)
unittests/CppInterOp/FunctionReflectionTest.cpp 99.74% <100.00%> (+<0.01%) ⬆️
unittests/CppInterOp/ScopeReflectionTest.cpp 100.00% <100.00%> (ø)
unittests/CppInterOp/TypeReflectionTest.cpp 99.61% <100.00%> (+<0.01%) ⬆️

... and 1 file with indirect coverage changes

Files Coverage Δ
lib/Interpreter/CppInterOp.cpp 77.47% <ø> (+2.26%) ⬆️
unittests/CppInterOp/EnumReflectionTest.cpp 100.00% <100.00%> (ø)
unittests/CppInterOp/FunctionReflectionTest.cpp 99.74% <100.00%> (+<0.01%) ⬆️
unittests/CppInterOp/ScopeReflectionTest.cpp 100.00% <100.00%> (ø)
unittests/CppInterOp/TypeReflectionTest.cpp 99.61% <100.00%> (+<0.01%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 18. Check the log or trigger a new build to see more.

@@ -119,6 +125,7 @@ TEST(EnumReflectionTest, GetIntegerTypeFromEnumScope) {
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetIntegerTypeFromEnumScope(Decls[2])), "int");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetIntegerTypeFromEnumScope(Decls[3])), "long long");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetIntegerTypeFromEnumScope(Decls[4])), "unsigned int");
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetIntegerTypeFromEnumScope(Decls[5])),"NULL TYPE");
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetIntegerTypeFromEnumScope(Decls[5])),"NULL TYPE");
                                                                        ^

EXPECT_EQ(get_int_type_from_enum_var(Decls[7]), "int");
EXPECT_EQ(get_int_type_from_enum_var(Decls[8]), "long long");
EXPECT_EQ(get_int_type_from_enum_var(Decls[9]), "unsigned int");
EXPECT_EQ(get_int_type_from_enum_var(Decls[5]), "NULL TYPE"); // When a nullptr is returned by GetVariableType()
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(get_int_type_from_enum_var(Decls[5]), "NULL TYPE"); // When a nullptr is returned by GetVariableType()
                                             ^

EXPECT_EQ(get_int_type_from_enum_var(Decls[8]), "long long");
EXPECT_EQ(get_int_type_from_enum_var(Decls[9]), "unsigned int");
EXPECT_EQ(get_int_type_from_enum_var(Decls[5]), "NULL TYPE"); // When a nullptr is returned by GetVariableType()
EXPECT_EQ(get_int_type_from_enum_var(Decls[6]), "bool");
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(get_int_type_from_enum_var(Decls[6]), "bool");
                                             ^

EXPECT_EQ(get_int_type_from_enum_var(Decls[9]), "unsigned int");
EXPECT_EQ(get_int_type_from_enum_var(Decls[5]), "NULL TYPE"); // When a nullptr is returned by GetVariableType()
EXPECT_EQ(get_int_type_from_enum_var(Decls[6]), "bool");
EXPECT_EQ(get_int_type_from_enum_var(Decls[7]), "char");
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(get_int_type_from_enum_var(Decls[7]), "char");
                                             ^

EXPECT_EQ(get_int_type_from_enum_var(Decls[5]), "NULL TYPE"); // When a nullptr is returned by GetVariableType()
EXPECT_EQ(get_int_type_from_enum_var(Decls[6]), "bool");
EXPECT_EQ(get_int_type_from_enum_var(Decls[7]), "char");
EXPECT_EQ(get_int_type_from_enum_var(Decls[8]), "int");
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 8 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(get_int_type_from_enum_var(Decls[8]), "int");
                                             ^

EXPECT_EQ(get_int_type_from_enum_var(Decls[6]), "bool");
EXPECT_EQ(get_int_type_from_enum_var(Decls[7]), "char");
EXPECT_EQ(get_int_type_from_enum_var(Decls[8]), "int");
EXPECT_EQ(get_int_type_from_enum_var(Decls[9]), "long long");
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(get_int_type_from_enum_var(Decls[9]), "long long");
                                             ^

EXPECT_EQ(get_int_type_from_enum_var(Decls[7]), "char");
EXPECT_EQ(get_int_type_from_enum_var(Decls[8]), "int");
EXPECT_EQ(get_int_type_from_enum_var(Decls[9]), "long long");
EXPECT_EQ(get_int_type_from_enum_var(Decls[10]), "unsigned int");
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 10 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(get_int_type_from_enum_var(Decls[10]), "unsigned int");
                                             ^

EXPECT_EQ(get_int_type_from_enum_var(Decls[8]), "int");
EXPECT_EQ(get_int_type_from_enum_var(Decls[9]), "long long");
EXPECT_EQ(get_int_type_from_enum_var(Decls[10]), "unsigned int");
EXPECT_EQ(get_int_type_from_enum_var(Decls[11]), "NULL TYPE"); // When a non Enum Type variable is used
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 11 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(get_int_type_from_enum_var(Decls[11]), "NULL TYPE"); // When a non Enum Type variable is used 
                                             ^

@@ -205,6 +225,7 @@
EXPECT_EQ(Cpp::GetEnumConstants(Decls[2]).size(), 2);
EXPECT_EQ(Cpp::GetEnumConstants(Decls[3]).size(), 3);
EXPECT_EQ(Cpp::GetEnumConstants(Decls[4]).size(), 4);
EXPECT_EQ(Cpp::GetEnumConstants(Decls[5]).size(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]

  EXPECT_EQ(Cpp::GetEnumConstants(Decls[5]).size(), 0);
                                        ^

)";

Cpp::CreateInterpreter();
Interp->declare(code);
std::vector<std::string> enumNames1, enumNames2;
std::vector<std::string> enumNames1, enumNames2, enumNames3, enumNames4;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'enumNames1' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<std::string> enumNames1, enumNames2, enumNames3, enumNames4;
std::vector<std::string> enumNames1 = 0, enumNames2, enumNames3, enumNames4;

@vgvassilev vgvassilev marked this pull request as ready for review October 19, 2023 15:25
Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

LGTM!

@vgvassilev vgvassilev merged commit 4669530 into compiler-research:main Oct 19, 2023
8 of 9 checks passed
Krishna-13-cyber pushed a commit to Krishna-13-cyber/CppInterOp that referenced this pull request Jan 4, 2024
* IsAggregate

* GetIntegerTypeFromEnumScope

* GetIntegerTypeFromEnumType

* GetEnumConstants

* GetCanonicalType

* GetType

* GetScopeFromType

* GetAllCppNames

* GetEnums

* GetBaseClass

* IsSubClass

* GetFunctionReturnType

* GetFunctionNumArgs

* GetFunctionRequiredArgs

* GetFunctionArgType

* GetFunctionSignature

* GetFunctionsUsingName

* HasDefaultConstructor

* IsComplete

* IsAbstract

* GetEnumConstantType

* GetEnumConstantValue

* GetUnderlyingScope

* GeTClassMethods

* GetDestructor
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