From ee55b56ef385023a290e495f6626ab7aeea2c5b8 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 24 Aug 2022 22:45:24 +0800 Subject: improve module deps --- .../c++/modules/headerunits_person/src/Person.mpp | 20 ++++++++++++++++++++ .../c++/modules/headerunits_person/src/test.cpp | 11 +++++++++++ .../projects/c++/modules/headerunits_person/test.lua | 1 + .../c++/modules/headerunits_person/xmake.lua | 4 ++++ tests/projects/c++/modules/partitions/test.lua | 1 + tests/projects/c++/modules/partitions2/src/math.cpp | 15 +++++++++++++++ tests/projects/c++/modules/partitions2/src/math.mpp | 7 +++++++ .../c++/modules/partitions2/src/math_helpers.cpp | 7 +++++++ tests/projects/c++/modules/partitions2/src/test.cpp | 7 +++++++ tests/projects/c++/modules/partitions2/xmake.lua | 4 ++++ 10 files changed, 77 insertions(+) create mode 100644 tests/projects/c++/modules/headerunits_person/src/Person.mpp create mode 100644 tests/projects/c++/modules/headerunits_person/src/test.cpp create mode 100644 tests/projects/c++/modules/headerunits_person/test.lua create mode 100644 tests/projects/c++/modules/headerunits_person/xmake.lua create mode 100644 tests/projects/c++/modules/partitions/test.lua create mode 100644 tests/projects/c++/modules/partitions2/src/math.cpp create mode 100644 tests/projects/c++/modules/partitions2/src/math.mpp create mode 100644 tests/projects/c++/modules/partitions2/src/math_helpers.cpp create mode 100644 tests/projects/c++/modules/partitions2/src/test.cpp create mode 100644 tests/projects/c++/modules/partitions2/xmake.lua (limited to 'tests/projects') diff --git a/tests/projects/c++/modules/headerunits_person/src/Person.mpp b/tests/projects/c++/modules/headerunits_person/src/Person.mpp new file mode 100644 index 000000000..e2dbf4044 --- /dev/null +++ b/tests/projects/c++/modules/headerunits_person/src/Person.mpp @@ -0,0 +1,20 @@ +module; + +#include // + +export module person; + +import ; + +export class Person { +public: + Person(std::string firstName, std::string lastName) + : m_firstName{std::move(firstName)}, m_lastName{std::move(lastName)} {} + + const std::string &getFirstName() const { return m_firstName; } + const std::string &getLastName() const { return m_lastName; } + +private: + std::string m_firstName; + std::string m_lastName; +}; diff --git a/tests/projects/c++/modules/headerunits_person/src/test.cpp b/tests/projects/c++/modules/headerunits_person/src/test.cpp new file mode 100644 index 000000000..7c01dc782 --- /dev/null +++ b/tests/projects/c++/modules/headerunits_person/src/test.cpp @@ -0,0 +1,11 @@ +import person; +import ; +import ; // For operator<< for std::string + +using namespace std; + +int main() +{ + Person person{ "Kole", "Webb" }; + cout << person.getLastName() << ", " << person.getFirstName() << endl; +} diff --git a/tests/projects/c++/modules/headerunits_person/test.lua b/tests/projects/c++/modules/headerunits_person/test.lua new file mode 100644 index 000000000..c18e5a1d0 --- /dev/null +++ b/tests/projects/c++/modules/headerunits_person/test.lua @@ -0,0 +1 @@ +inherit(".test_headerunits") diff --git a/tests/projects/c++/modules/headerunits_person/xmake.lua b/tests/projects/c++/modules/headerunits_person/xmake.lua new file mode 100644 index 000000000..c9290833b --- /dev/null +++ b/tests/projects/c++/modules/headerunits_person/xmake.lua @@ -0,0 +1,4 @@ +set_languages("c++20") +target("hello") + set_kind("binary") + add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/partitions/test.lua b/tests/projects/c++/modules/partitions/test.lua new file mode 100644 index 000000000..c18e5a1d0 --- /dev/null +++ b/tests/projects/c++/modules/partitions/test.lua @@ -0,0 +1 @@ +inherit(".test_headerunits") diff --git a/tests/projects/c++/modules/partitions2/src/math.cpp b/tests/projects/c++/modules/partitions2/src/math.cpp new file mode 100644 index 000000000..535d693eb --- /dev/null +++ b/tests/projects/c++/modules/partitions2/src/math.cpp @@ -0,0 +1,15 @@ +module math; + +import :details; + +double Math::superLog(double z, double b) +{ + // Implementation omitted... + return someHelperFunction(z); +} + +double Math::lerchZeta(double lambda, double alpha, double s) +{ + // Implementation omitted... + return someHelperFunction(s); +} diff --git a/tests/projects/c++/modules/partitions2/src/math.mpp b/tests/projects/c++/modules/partitions2/src/math.mpp new file mode 100644 index 000000000..e9308b2af --- /dev/null +++ b/tests/projects/c++/modules/partitions2/src/math.mpp @@ -0,0 +1,7 @@ +export module math; // math module declaration + +export namespace Math +{ + double superLog(double z, double b); + double lerchZeta(double lambda, double alpha, double s); +} diff --git a/tests/projects/c++/modules/partitions2/src/math_helpers.cpp b/tests/projects/c++/modules/partitions2/src/math_helpers.cpp new file mode 100644 index 000000000..9d2eaaa27 --- /dev/null +++ b/tests/projects/c++/modules/partitions2/src/math_helpers.cpp @@ -0,0 +1,7 @@ +module math:details; // math:details implementation partition + +double someHelperFunction(double a) +{ + // Implementation omitted... + return 42; +} diff --git a/tests/projects/c++/modules/partitions2/src/test.cpp b/tests/projects/c++/modules/partitions2/src/test.cpp new file mode 100644 index 000000000..a2ff757b1 --- /dev/null +++ b/tests/projects/c++/modules/partitions2/src/test.cpp @@ -0,0 +1,7 @@ +import math; + +int main() +{ + auto a{ Math::lerchZeta(1, 2, 3) }; + auto b{ Math::superLog(1, 2) }; +} diff --git a/tests/projects/c++/modules/partitions2/xmake.lua b/tests/projects/c++/modules/partitions2/xmake.lua new file mode 100644 index 000000000..c9290833b --- /dev/null +++ b/tests/projects/c++/modules/partitions2/xmake.lua @@ -0,0 +1,4 @@ +set_languages("c++20") +target("hello") + set_kind("binary") + add_files("src/*.cpp", "src/*.mpp") -- cgit v1.3.1