diff options
| author | ruki <[email protected]> | 2024-03-14 00:51:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-14 00:51:32 +0800 |
| commit | 218abfd90286dd906f28c368802fd755808f1ab9 (patch) | |
| tree | 469d74e7fba4e6c32366c1dc0d5037a4e9bed6a8 /tests/projects/c++/modules/partitions_implunit | |
| parent | 53cc8033c4b7970afb13e89cb6b79272e71fbfda (diff) | |
improve tests
Diffstat (limited to 'tests/projects/c++/modules/partitions_implunit')
10 files changed, 39 insertions, 41 deletions
diff --git a/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Point.mpp b/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Point.mpp deleted file mode 100644 index e693edcc0..000000000 --- a/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Point.mpp +++ /dev/null @@ -1,5 +0,0 @@ -export module BasicPlane.Figures:Point;
-
-export struct Point {
- int x, y;
-};
diff --git a/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Rectangle.cpp b/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Rectangle.cpp deleted file mode 100644 index ca05e05a1..000000000 --- a/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Rectangle.cpp +++ /dev/null @@ -1,7 +0,0 @@ -module; - -module BasicPlane.Figures; - -int area(const Rectangle& r) { return width(r) * height(r); } -int height(const Rectangle& r) { return r.ul.y - r.lr.y; } -int width(const Rectangle& r) { return r.lr.x - r.ul.x; } diff --git a/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Rectangle.mpp b/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Rectangle.mpp deleted file mode 100644 index 84467d480..000000000 --- a/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures-Rectangle.mpp +++ /dev/null @@ -1,11 +0,0 @@ -export module BasicPlane.Figures:Rectangle;
-
-import :Point;
-
-export struct Rectangle {
- Point ul, lr;
-};
-
-export int area(const Rectangle& r);
-export int height(const Rectangle& r);
-export int width(const Rectangle& r);
diff --git a/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures.mpp b/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures.mpp deleted file mode 100644 index f471e1436..000000000 --- a/tests/projects/c++/modules/partitions_implunit/src/BasicPlane.Figures.mpp +++ /dev/null @@ -1,4 +0,0 @@ -export module BasicPlane.Figures; - -export import :Point; -export import :Rectangle; diff --git a/tests/projects/c++/modules/partitions_implunit/src/ModulesTutorial.cpp b/tests/projects/c++/modules/partitions_implunit/src/ModulesTutorial.cpp deleted file mode 100644 index 130a5778c..000000000 --- a/tests/projects/c++/modules/partitions_implunit/src/ModulesTutorial.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include <iostream> - -import BasicPlane.Figures; - -int main(int argc, char** argv) { - Rectangle r{ {1,8}, {11,3} }; - std::cout << "area: " << area(r) << '\n'; - std::cout << "width: " << width(r) << '\n'; - return 0; -} diff --git a/tests/projects/c++/modules/partitions_implunit/src/math.cpp b/tests/projects/c++/modules/partitions_implunit/src/math.cpp new file mode 100644 index 000000000..3a10c8203 --- /dev/null +++ b/tests/projects/c++/modules/partitions_implunit/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/partitions_implunit/src/math.mpp b/tests/projects/c++/modules/partitions_implunit/src/math.mpp new file mode 100644 index 000000000..9e2552513 --- /dev/null +++ b/tests/projects/c++/modules/partitions_implunit/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/partitions_implunit/src/math_impl.mpp b/tests/projects/c++/modules/partitions_implunit/src/math_impl.mpp new file mode 100644 index 000000000..a92cb5e4a --- /dev/null +++ b/tests/projects/c++/modules/partitions_implunit/src/math_impl.mpp @@ -0,0 +1,7 @@ +export module math:details; // math:details implementation partition
+
+double someHelperFunction(double a)
+{
+ // Implementation omitted...
+ return 42;
+}
diff --git a/tests/projects/c++/modules/partitions_implunit/src/test.cpp b/tests/projects/c++/modules/partitions_implunit/src/test.cpp new file mode 100644 index 000000000..8f7f81b2c --- /dev/null +++ b/tests/projects/c++/modules/partitions_implunit/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/partitions_implunit/xmake.lua b/tests/projects/c++/modules/partitions_implunit/xmake.lua index a777846e3..9e0ab37bb 100644 --- a/tests/projects/c++/modules/partitions_implunit/xmake.lua +++ b/tests/projects/c++/modules/partitions_implunit/xmake.lua @@ -1,7 +1,6 @@ add_rules("mode.release", "mode.debug")
set_languages("c++20")
-target("foo")
- set_kind("static")
- add_files("src/*.cpp")
- add_files("src/*.mpp")
+target("partition2")
+ set_kind("binary")
+ add_files("src/*.cpp", "src/*.mpp")
|
