summaryrefslogtreecommitdiff
path: root/tests/projects/c++/modules/namespace2/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/projects/c++/modules/namespace2/src')
-rw-r--r--tests/projects/c++/modules/namespace2/src/hello.mpp14
-rw-r--r--tests/projects/c++/modules/namespace2/src/hello_impl.cpp23
-rw-r--r--tests/projects/c++/modules/namespace2/src/main.cpp9
-rw-r--r--tests/projects/c++/modules/namespace2/src/mod.mpp5
-rw-r--r--tests/projects/c++/modules/namespace2/src/mod_impl.cpp8
5 files changed, 59 insertions, 0 deletions
diff --git a/tests/projects/c++/modules/namespace2/src/hello.mpp b/tests/projects/c++/modules/namespace2/src/hello.mpp
new file mode 100644
index 000000000..abac9fcb0
--- /dev/null
+++ b/tests/projects/c++/modules/namespace2/src/hello.mpp
@@ -0,0 +1,14 @@
+export module hello;
+
+export namespace hello {
+ extern int data__;
+ void say_hello();
+
+ class say {
+ public:
+ say(int data);
+ void hello();
+ private:
+ int data_;
+ };
+}
diff --git a/tests/projects/c++/modules/namespace2/src/hello_impl.cpp b/tests/projects/c++/modules/namespace2/src/hello_impl.cpp
new file mode 100644
index 000000000..064afebad
--- /dev/null
+++ b/tests/projects/c++/modules/namespace2/src/hello_impl.cpp
@@ -0,0 +1,23 @@
+module;
+#include <iostream>
+
+module hello;
+import mod;
+
+void inner() {
+ std::cout << "hello world! data: "
+ << mod::foo() << std::endl;
+}
+
+namespace hello {
+ int data__;
+ void say_hello() { ::inner(); }
+
+ say::say(int data) : data_{data} {
+ }
+
+ void say::hello() {
+ hello::data__ = data_;
+ ::inner();
+ }
+}
diff --git a/tests/projects/c++/modules/namespace2/src/main.cpp b/tests/projects/c++/modules/namespace2/src/main.cpp
new file mode 100644
index 000000000..93cc427a4
--- /dev/null
+++ b/tests/projects/c++/modules/namespace2/src/main.cpp
@@ -0,0 +1,9 @@
+import hello;
+
+int main() {
+ hello::data__ = 123;
+ hello::say_hello();
+ hello::say(sizeof(hello::say)).hello();
+ return 0;
+}
+
diff --git a/tests/projects/c++/modules/namespace2/src/mod.mpp b/tests/projects/c++/modules/namespace2/src/mod.mpp
new file mode 100644
index 000000000..ac30a31c8
--- /dev/null
+++ b/tests/projects/c++/modules/namespace2/src/mod.mpp
@@ -0,0 +1,5 @@
+export module mod;
+
+export namespace mod {
+ int foo();
+}
diff --git a/tests/projects/c++/modules/namespace2/src/mod_impl.cpp b/tests/projects/c++/modules/namespace2/src/mod_impl.cpp
new file mode 100644
index 000000000..1adf6570e
--- /dev/null
+++ b/tests/projects/c++/modules/namespace2/src/mod_impl.cpp
@@ -0,0 +1,8 @@
+module mod;
+import hello;
+
+namespace mod {
+ int foo() {
+ return hello::data__;
+ }
+}