diff --git a/C/CMakeLists.txt b/C/CMakeLists.txt index 6b4ffcdd..9cd8c0fc 100644 --- a/C/CMakeLists.txt +++ b/C/CMakeLists.txt @@ -234,6 +234,8 @@ set(CFE_SOURCES ${PROJECT_SOURCE_DIR}/tests/ParserTester_3000_3999.cpp ${PROJECT_SOURCE_DIR}/tests/ReparserTester.h ${PROJECT_SOURCE_DIR}/tests/ReparserTester.cpp + ${PROJECT_SOURCE_DIR}/tests/DeclarationResolverTester.h + ${PROJECT_SOURCE_DIR}/tests/DeclarationResolverTester.cpp ${PROJECT_SOURCE_DIR}/tests/SemanticModelTester.h ${PROJECT_SOURCE_DIR}/tests/SemanticModelTester.cpp ${PROJECT_SOURCE_DIR}/tests/TestExpectation.h diff --git a/C/binder/DeclarationResolver.cpp b/C/binder/DeclarationResolver.cpp index 6ceca5fa..70b53a40 100644 --- a/C/binder/DeclarationResolver.cpp +++ b/C/binder/DeclarationResolver.cpp @@ -78,6 +78,7 @@ SyntaxVisitor::Action DeclarationResolver::visitIdentifierDeclarator(const Ident NameSpace::OrdinaryIdentifiers); if (tyDecl) { // TODO + std::cout << "got it " << std::endl; } break; } diff --git a/C/tests/DeclarationResolverTester.cpp b/C/tests/DeclarationResolverTester.cpp new file mode 100644 index 00000000..3241f1fa --- /dev/null +++ b/C/tests/DeclarationResolverTester.cpp @@ -0,0 +1,67 @@ +// Copyright (c) 2024 Leandro T. C. Melo +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#include "DeclarationResolverTester.h" + +using namespace psy; +using namespace C; + +const std::string DeclarationResolverTester::Name = "DECLARATION-RESOLVER"; + +void DeclarationResolverTester::testDeclarationResolver() +{ + return run(tests_); +} + +void DeclarationResolverTester::resolve(std::string text, Expectation X) +{ + (static_cast(suite_)->resolve(text, X)); +} + +void DeclarationResolverTester::case0000(){} +void DeclarationResolverTester::case0001(){} +void DeclarationResolverTester::case0002(){} +void DeclarationResolverTester::case0003(){} +void DeclarationResolverTester::case0004(){} +void DeclarationResolverTester::case0005(){} +void DeclarationResolverTester::case0006(){} +void DeclarationResolverTester::case0007(){} +void DeclarationResolverTester::case0008(){} +void DeclarationResolverTester::case0009(){} +void DeclarationResolverTester::case0010(){} +void DeclarationResolverTester::case0011(){} +void DeclarationResolverTester::case0012(){} +void DeclarationResolverTester::case0013(){} +void DeclarationResolverTester::case0014(){} +void DeclarationResolverTester::case0015(){} +void DeclarationResolverTester::case0016(){} +void DeclarationResolverTester::case0017(){} +void DeclarationResolverTester::case0018(){} +void DeclarationResolverTester::case0019(){} +void DeclarationResolverTester::case0020(){} +void DeclarationResolverTester::case0021(){} +void DeclarationResolverTester::case0022(){} +void DeclarationResolverTester::case0023(){} +void DeclarationResolverTester::case0024(){} +void DeclarationResolverTester::case0025(){} +void DeclarationResolverTester::case0026(){} +void DeclarationResolverTester::case0027(){} +void DeclarationResolverTester::case0028(){} +void DeclarationResolverTester::case0029(){} diff --git a/C/tests/DeclarationResolverTester.h b/C/tests/DeclarationResolverTester.h new file mode 100644 index 00000000..fc25552b --- /dev/null +++ b/C/tests/DeclarationResolverTester.h @@ -0,0 +1,123 @@ +// Copyright (c) 2024 Leandro T. C. Melo +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#ifndef PSYCHE_C_DECLARATION_RESOLVER_TESTER_H__ +#define PSYCHE_C_DECLARATION_RESOLVER_TESTER_H__ + +#include "Fwds.h" +#include "TestSuite_Internals.h" +#include "tests/Tester.h" + +#define TEST_DECLARATION_RESOLVER(Function) TestFunction { &DeclarationResolverTester::Function, #Function } + +namespace psy { +namespace C { + +class DeclarationResolverTester final : public Tester +{ +public: + DeclarationResolverTester(TestSuite* suite) + : Tester(suite) + {} + + static const std::string Name; + virtual std::string name() const override { return Name; } + + void testDeclarationResolver(); + + void resolve(std::string text, Expectation X); + + using TestFunction = std::pair, const char*>; + + /* + xxxx + + 0000-0099 -> multiplication x pointer declaration + */ + + void case0000(); + void case0001(); + void case0002(); + void case0003(); + void case0004(); + void case0005(); + void case0006(); + void case0007(); + void case0008(); + void case0009(); + void case0010(); + void case0011(); + void case0012(); + void case0013(); + void case0014(); + void case0015(); + void case0016(); + void case0017(); + void case0018(); + void case0019(); + void case0020(); + void case0021(); + void case0022(); + void case0023(); + void case0024(); + void case0025(); + void case0026(); + void case0027(); + void case0028(); + void case0029(); + + std::vector tests_ + { + TEST_DECLARATION_RESOLVER(case0000), + TEST_DECLARATION_RESOLVER(case0001), + TEST_DECLARATION_RESOLVER(case0002), + TEST_DECLARATION_RESOLVER(case0003), + TEST_DECLARATION_RESOLVER(case0004), + TEST_DECLARATION_RESOLVER(case0005), + TEST_DECLARATION_RESOLVER(case0006), + TEST_DECLARATION_RESOLVER(case0007), + TEST_DECLARATION_RESOLVER(case0008), + TEST_DECLARATION_RESOLVER(case0009), + TEST_DECLARATION_RESOLVER(case0010), + TEST_DECLARATION_RESOLVER(case0011), + TEST_DECLARATION_RESOLVER(case0012), + TEST_DECLARATION_RESOLVER(case0013), + TEST_DECLARATION_RESOLVER(case0014), + TEST_DECLARATION_RESOLVER(case0015), + TEST_DECLARATION_RESOLVER(case0016), + TEST_DECLARATION_RESOLVER(case0017), + TEST_DECLARATION_RESOLVER(case0018), + TEST_DECLARATION_RESOLVER(case0019), + TEST_DECLARATION_RESOLVER(case0020), + TEST_DECLARATION_RESOLVER(case0021), + TEST_DECLARATION_RESOLVER(case0022), + TEST_DECLARATION_RESOLVER(case0023), + TEST_DECLARATION_RESOLVER(case0024), + TEST_DECLARATION_RESOLVER(case0025), + TEST_DECLARATION_RESOLVER(case0026), + TEST_DECLARATION_RESOLVER(case0027), + TEST_DECLARATION_RESOLVER(case0028), + TEST_DECLARATION_RESOLVER(case0029), + }; +}; + +} // C +} // psy + +#endif diff --git a/C/tests/TestSuite_Internals.cpp b/C/tests/TestSuite_Internals.cpp index d4e0b593..96094880 100644 --- a/C/tests/TestSuite_Internals.cpp +++ b/C/tests/TestSuite_Internals.cpp @@ -32,6 +32,7 @@ #include "BinderTester.h" #include "ParserTester.h" #include "ReparserTester.h" +#include "DeclarationResolverTester.h" #include "../common/infra/Assertions.h" @@ -66,16 +67,22 @@ std::tuple InternalsTestSuite::testAll() auto C = std::make_unique(this); C->testBinder(); + auto D = std::make_unique(this); + D->testDeclarationResolver(); + auto res = std::make_tuple(P->totalPassed() + B->totalPassed() - + C->totalPassed(), + + C->totalPassed() + + D->totalPassed(), P->totalFailed() + B->totalFailed() - + C->totalFailed()); + + C->totalFailed() + + D->totalFailed()); testers_.emplace_back(P.release()); testers_.emplace_back(B.release()); testers_.emplace_back(C.release()); + testers_.emplace_back(D.release()); return res; } @@ -776,5 +783,14 @@ void InternalsTestSuite::bind(std::string text, Expectation X) PSY_EXPECT_TRUE(sameDecl); PSY_EXPECT_TRUE(symbolMatchesBinding(sameDecl, declSummary)); } + + // resolution + // decl } } + +void InternalsTestSuite::resolve(std::string text, Expectation X) +{ + bind(text, X); +} + diff --git a/C/tests/TestSuite_Internals.h b/C/tests/TestSuite_Internals.h index 7e8f708f..520225c9 100644 --- a/C/tests/TestSuite_Internals.h +++ b/C/tests/TestSuite_Internals.h @@ -43,6 +43,7 @@ class InternalsTestSuite : public TestSuite friend class ParserTester; friend class ReparserTester; friend class BinderTester; + friend class DeclarationResolverTester; public: virtual ~InternalsTestSuite(); @@ -71,6 +72,8 @@ class InternalsTestSuite : public TestSuite void bind(std::string text, Expectation X = Expectation()); + void resolve(std::string text, Expectation X = Expectation()); + std::unique_ptr tree_; std::unique_ptr compilation_; std::vector> testers_;