summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/projects/c++/modules/class/src/hello.mpp12
-rw-r--r--tests/projects/c++/modules/class/src/hello_impl.cpp16
-rw-r--r--tests/projects/c++/modules/class/src/main.cpp7
-rw-r--r--tests/projects/c++/modules/class/xmake.lua5
-rw-r--r--tests/projects/c++/modules/dependence/src/hello.mpp26
-rw-r--r--tests/projects/c++/modules/dependence/src/hello_impl.cpp23
-rw-r--r--tests/projects/c++/modules/dependence/src/main.cpp9
-rw-r--r--tests/projects/c++/modules/dependence/src/mod.mpp5
-rw-r--r--tests/projects/c++/modules/dependence/src/mod_impl.cpp8
-rw-r--r--tests/projects/c++/modules/dependence/xmake.lua6
-rw-r--r--tests/projects/c++/modules/hello/src/hello.mpp10
-rw-r--r--tests/projects/c++/modules/hello/src/main.cpp6
-rw-r--r--tests/projects/c++/modules/hello/xmake.lua5
-rw-r--r--tests/projects/c++/modules/impl_unit/src/hello.mpp10
-rw-r--r--tests/projects/c++/modules/impl_unit/src/hello_impl.cpp19
-rw-r--r--tests/projects/c++/modules/impl_unit/src/main.cpp8
-rw-r--r--tests/projects/c++/modules/impl_unit/xmake.lua5
-rw-r--r--tests/projects/c++/modules/inline_and_template/src/foo.mpp17
-rw-r--r--tests/projects/c++/modules/inline_and_template/src/foo_impl.cpp8
-rw-r--r--tests/projects/c++/modules/inline_and_template/src/hello.mpp9
-rw-r--r--tests/projects/c++/modules/inline_and_template/src/main.cpp12
-rw-r--r--tests/projects/c++/modules/inline_and_template/src/say.mpp11
-rw-r--r--tests/projects/c++/modules/inline_and_template/xmake.lua6
-rw-r--r--tests/projects/objc++/modulemap/src/hello.h7
-rw-r--r--tests/projects/objc++/modulemap/src/hello.m10
-rw-r--r--tests/projects/objc++/modulemap/src/main.mm8
-rw-r--r--tests/projects/objc++/modulemap/src/module.modulemap4
-rw-r--r--tests/projects/objc++/modulemap/xmake.lua6
-rw-r--r--tests/projects/objc/modulemap/src/hello.h7
-rw-r--r--tests/projects/objc/modulemap/src/hello.m10
-rw-r--r--tests/projects/objc/modulemap/src/main.m8
-rw-r--r--tests/projects/objc/modulemap/src/module.modulemap4
-rw-r--r--tests/projects/objc/modulemap/xmake.lua6
-rw-r--r--tests/projects/swift/modulemap/src/hello.cpp8
-rw-r--r--tests/projects/swift/modulemap/src/hello.h14
-rw-r--r--tests/projects/swift/modulemap/src/main.swift5
-rw-r--r--tests/projects/swift/modulemap/src/module.modulemap4
-rw-r--r--tests/projects/swift/modulemap/xmake.lua4
38 files changed, 348 insertions, 0 deletions
diff --git a/tests/projects/c++/modules/class/src/hello.mpp b/tests/projects/c++/modules/class/src/hello.mpp
new file mode 100644
index 000000000..9e4ecd960
--- /dev/null
+++ b/tests/projects/c++/modules/class/src/hello.mpp
@@ -0,0 +1,12 @@
+export module hello;
+
+export namespace hello {
+ class say {
+ public:
+ say(int data);
+ void hello();
+
+ private:
+ int data_;
+ };
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/class/src/hello_impl.cpp b/tests/projects/c++/modules/class/src/hello_impl.cpp
new file mode 100644
index 000000000..b929c453b
--- /dev/null
+++ b/tests/projects/c++/modules/class/src/hello_impl.cpp
@@ -0,0 +1,16 @@
+// module;
+#include <iostream>
+module hello;
+
+// import std.core;
+using namespace std;
+
+namespace hello {
+ say::say(int data) : data_(data) {
+
+ }
+
+ void say::hello() {
+ cout << "hello, say class: " << data_ << endl;
+ }
+}
diff --git a/tests/projects/c++/modules/class/src/main.cpp b/tests/projects/c++/modules/class/src/main.cpp
new file mode 100644
index 000000000..6f80b6c7d
--- /dev/null
+++ b/tests/projects/c++/modules/class/src/main.cpp
@@ -0,0 +1,7 @@
+import hello;
+
+int main() {
+ hello::say s(sizeof(hello::say));
+ s.hello();
+ return 0;
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/class/xmake.lua b/tests/projects/c++/modules/class/xmake.lua
new file mode 100644
index 000000000..f0dcc3ea7
--- /dev/null
+++ b/tests/projects/c++/modules/class/xmake.lua
@@ -0,0 +1,5 @@
+target("class")
+ set_kind("binary")
+ add_files("src/*.cpp", "src/*.mpp")
+
+
diff --git a/tests/projects/c++/modules/dependence/src/hello.mpp b/tests/projects/c++/modules/dependence/src/hello.mpp
new file mode 100644
index 000000000..e29bd7b95
--- /dev/null
+++ b/tests/projects/c++/modules/dependence/src/hello.mpp
@@ -0,0 +1,26 @@
+export module hello;
+
+export namespace hello {
+#ifdef _MSC_VER
+ int data__;
+#else
+ extern int data__;
+#endif
+ void say_hello();
+
+ class say {
+ public:
+ say(int data);
+ void hello();
+
+ private:
+ int data_;
+ };
+}
+
+#ifndef _MSC_VER
+export namespace {
+ void anonymous() {
+ }
+}
+#endif
diff --git a/tests/projects/c++/modules/dependence/src/hello_impl.cpp b/tests/projects/c++/modules/dependence/src/hello_impl.cpp
new file mode 100644
index 000000000..37797c31c
--- /dev/null
+++ b/tests/projects/c++/modules/dependence/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/dependence/src/main.cpp b/tests/projects/c++/modules/dependence/src/main.cpp
new file mode 100644
index 000000000..93cc427a4
--- /dev/null
+++ b/tests/projects/c++/modules/dependence/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/dependence/src/mod.mpp b/tests/projects/c++/modules/dependence/src/mod.mpp
new file mode 100644
index 000000000..ac30a31c8
--- /dev/null
+++ b/tests/projects/c++/modules/dependence/src/mod.mpp
@@ -0,0 +1,5 @@
+export module mod;
+
+export namespace mod {
+ int foo();
+}
diff --git a/tests/projects/c++/modules/dependence/src/mod_impl.cpp b/tests/projects/c++/modules/dependence/src/mod_impl.cpp
new file mode 100644
index 000000000..1adf6570e
--- /dev/null
+++ b/tests/projects/c++/modules/dependence/src/mod_impl.cpp
@@ -0,0 +1,8 @@
+module mod;
+import hello;
+
+namespace mod {
+ int foo() {
+ return hello::data__;
+ }
+}
diff --git a/tests/projects/c++/modules/dependence/xmake.lua b/tests/projects/c++/modules/dependence/xmake.lua
new file mode 100644
index 000000000..4a2608cd3
--- /dev/null
+++ b/tests/projects/c++/modules/dependence/xmake.lua
@@ -0,0 +1,6 @@
+target("dependence")
+ set_kind("binary")
+ add_files("src/*.cpp", "src/*.mpp")
+ set_languages("c++11")
+
+
diff --git a/tests/projects/c++/modules/hello/src/hello.mpp b/tests/projects/c++/modules/hello/src/hello.mpp
new file mode 100644
index 000000000..fbd7fd6ad
--- /dev/null
+++ b/tests/projects/c++/modules/hello/src/hello.mpp
@@ -0,0 +1,10 @@
+// module;
+#include <cstdio>
+export module hello;
+using namespace std;
+
+export namespace hello {
+ void say(const char* str) {
+ printf("%s\n", str);
+ }
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/hello/src/main.cpp b/tests/projects/c++/modules/hello/src/main.cpp
new file mode 100644
index 000000000..175b4d348
--- /dev/null
+++ b/tests/projects/c++/modules/hello/src/main.cpp
@@ -0,0 +1,6 @@
+import hello;
+
+int main() {
+ hello::say("hello module!");
+ return 0;
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/hello/xmake.lua b/tests/projects/c++/modules/hello/xmake.lua
new file mode 100644
index 000000000..e22047e4b
--- /dev/null
+++ b/tests/projects/c++/modules/hello/xmake.lua
@@ -0,0 +1,5 @@
+target("hello")
+ set_kind("binary")
+ add_files("src/*.cpp", "src/*.mpp")
+
+
diff --git a/tests/projects/c++/modules/impl_unit/src/hello.mpp b/tests/projects/c++/modules/impl_unit/src/hello.mpp
new file mode 100644
index 000000000..0b65bf24e
--- /dev/null
+++ b/tests/projects/c++/modules/impl_unit/src/hello.mpp
@@ -0,0 +1,10 @@
+export module hello;
+
+namespace hello {
+ void say_hi();
+}
+
+export namespace hello {
+ void say_hello();
+ void say_xz();
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/impl_unit/src/hello_impl.cpp b/tests/projects/c++/modules/impl_unit/src/hello_impl.cpp
new file mode 100644
index 000000000..1c9968a51
--- /dev/null
+++ b/tests/projects/c++/modules/impl_unit/src/hello_impl.cpp
@@ -0,0 +1,19 @@
+// module;
+#include <iostream>
+module hello;
+
+using namespace std;
+
+namespace hello {
+ void say_hi() {
+ cout << "hello hi!" << endl;
+ }
+
+ void say_hello() {
+ cout << "hello world!" << endl;
+ }
+
+ void say_xz() {
+ cout << "hello xz!" << endl;
+ }
+}
diff --git a/tests/projects/c++/modules/impl_unit/src/main.cpp b/tests/projects/c++/modules/impl_unit/src/main.cpp
new file mode 100644
index 000000000..378861561
--- /dev/null
+++ b/tests/projects/c++/modules/impl_unit/src/main.cpp
@@ -0,0 +1,8 @@
+import hello;
+
+int main() {
+ hello::say_hello();
+ hello::say_xz();
+ // hello::say_hi();
+ return 0;
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/impl_unit/xmake.lua b/tests/projects/c++/modules/impl_unit/xmake.lua
new file mode 100644
index 000000000..1ce6cb8b6
--- /dev/null
+++ b/tests/projects/c++/modules/impl_unit/xmake.lua
@@ -0,0 +1,5 @@
+target("impl_unit")
+ set_kind("binary")
+ add_files("src/*.cpp", "src/*.mpp")
+
+
diff --git a/tests/projects/c++/modules/inline_and_template/src/foo.mpp b/tests/projects/c++/modules/inline_and_template/src/foo.mpp
new file mode 100644
index 000000000..03e15d413
--- /dev/null
+++ b/tests/projects/c++/modules/inline_and_template/src/foo.mpp
@@ -0,0 +1,17 @@
+export module foo;
+
+export {
+ template <typename>
+ struct foo {
+ constexpr const char* hello(void) const {
+ return "hello typename!";
+ }
+ };
+
+ // template <>
+ // struct foo<int> {
+ // constexpr const char* hello(void) const {
+ // return "hello typename int!";
+ // }
+ // };
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/inline_and_template/src/foo_impl.cpp b/tests/projects/c++/modules/inline_and_template/src/foo_impl.cpp
new file mode 100644
index 000000000..c44ef849b
--- /dev/null
+++ b/tests/projects/c++/modules/inline_and_template/src/foo_impl.cpp
@@ -0,0 +1,8 @@
+module foo;
+
+template <>
+struct foo<int> {
+ constexpr const char* hello(void) const {
+ return "hello int!";
+ }
+}; \ No newline at end of file
diff --git a/tests/projects/c++/modules/inline_and_template/src/hello.mpp b/tests/projects/c++/modules/inline_and_template/src/hello.mpp
new file mode 100644
index 000000000..1796f0b11
--- /dev/null
+++ b/tests/projects/c++/modules/inline_and_template/src/hello.mpp
@@ -0,0 +1,9 @@
+// module;
+#include <cstdio>
+export module hello;
+
+export namespace hello {
+ inline void say_hello() {
+ std::printf("hello world!\n");
+ }
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/inline_and_template/src/main.cpp b/tests/projects/c++/modules/inline_and_template/src/main.cpp
new file mode 100644
index 000000000..a34667fbe
--- /dev/null
+++ b/tests/projects/c++/modules/inline_and_template/src/main.cpp
@@ -0,0 +1,12 @@
+import hello;
+import say;
+import foo;
+
+#include <iostream>
+
+int main() {
+ hello::say_hello();
+ say{}.hello<sizeof(say)>();
+ std::cout << foo<int>{}.hello() << std::endl;
+ return 0;
+} \ No newline at end of file
diff --git a/tests/projects/c++/modules/inline_and_template/src/say.mpp b/tests/projects/c++/modules/inline_and_template/src/say.mpp
new file mode 100644
index 000000000..d09e14d28
--- /dev/null
+++ b/tests/projects/c++/modules/inline_and_template/src/say.mpp
@@ -0,0 +1,11 @@
+// module;
+#include <cstdio>
+export module say;
+
+export class say {
+public:
+ template <int N>
+ void hello() {
+ std::printf("hello, say class: %d\n", N);
+ }
+}; \ No newline at end of file
diff --git a/tests/projects/c++/modules/inline_and_template/xmake.lua b/tests/projects/c++/modules/inline_and_template/xmake.lua
new file mode 100644
index 000000000..e22a0ef04
--- /dev/null
+++ b/tests/projects/c++/modules/inline_and_template/xmake.lua
@@ -0,0 +1,6 @@
+target("inline_and_template")
+ set_kind("binary")
+ add_files("src/*.cpp", "src/*.mpp")
+ set_languages("c++11")
+
+
diff --git a/tests/projects/objc++/modulemap/src/hello.h b/tests/projects/objc++/modulemap/src/hello.h
new file mode 100644
index 000000000..7eb60b9e6
--- /dev/null
+++ b/tests/projects/objc++/modulemap/src/hello.h
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+@interface Hello : NSObject
+
++ (void)say:(NSString*)s;
+
+@end
diff --git a/tests/projects/objc++/modulemap/src/hello.m b/tests/projects/objc++/modulemap/src/hello.m
new file mode 100644
index 000000000..b22f844f2
--- /dev/null
+++ b/tests/projects/objc++/modulemap/src/hello.m
@@ -0,0 +1,10 @@
+#import "hello.h"
+
+@implementation Hello
+
++ (void)say:(NSString*)s
+{
+ NSLog(@"%@\n", s);
+}
+
+@end
diff --git a/tests/projects/objc++/modulemap/src/main.mm b/tests/projects/objc++/modulemap/src/main.mm
new file mode 100644
index 000000000..5f6fd74cb
--- /dev/null
+++ b/tests/projects/objc++/modulemap/src/main.mm
@@ -0,0 +1,8 @@
+#import <Foundation/Foundation.h>
+@import Hello;
+
+int main(int argc, char** argv)
+{
+ [Hello say:@"hello"];
+ return 0;
+}
diff --git a/tests/projects/objc++/modulemap/src/module.modulemap b/tests/projects/objc++/modulemap/src/module.modulemap
new file mode 100644
index 000000000..91a9c4235
--- /dev/null
+++ b/tests/projects/objc++/modulemap/src/module.modulemap
@@ -0,0 +1,4 @@
+module Hello {
+ header "hello.h"
+ export *
+}
diff --git a/tests/projects/objc++/modulemap/xmake.lua b/tests/projects/objc++/modulemap/xmake.lua
new file mode 100644
index 000000000..a7cdbc308
--- /dev/null
+++ b/tests/projects/objc++/modulemap/xmake.lua
@@ -0,0 +1,6 @@
+target("modulemap")
+ set_kind("binary")
+ add_files("src/*.mm", "src/*.m")
+ add_mxxflags("-fmodules", "-fcxx-modules", "-fmodule-map-file=src/module.modulemap")
+
+
diff --git a/tests/projects/objc/modulemap/src/hello.h b/tests/projects/objc/modulemap/src/hello.h
new file mode 100644
index 000000000..7eb60b9e6
--- /dev/null
+++ b/tests/projects/objc/modulemap/src/hello.h
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+@interface Hello : NSObject
+
++ (void)say:(NSString*)s;
+
+@end
diff --git a/tests/projects/objc/modulemap/src/hello.m b/tests/projects/objc/modulemap/src/hello.m
new file mode 100644
index 000000000..b22f844f2
--- /dev/null
+++ b/tests/projects/objc/modulemap/src/hello.m
@@ -0,0 +1,10 @@
+#import "hello.h"
+
+@implementation Hello
+
++ (void)say:(NSString*)s
+{
+ NSLog(@"%@\n", s);
+}
+
+@end
diff --git a/tests/projects/objc/modulemap/src/main.m b/tests/projects/objc/modulemap/src/main.m
new file mode 100644
index 000000000..5f6fd74cb
--- /dev/null
+++ b/tests/projects/objc/modulemap/src/main.m
@@ -0,0 +1,8 @@
+#import <Foundation/Foundation.h>
+@import Hello;
+
+int main(int argc, char** argv)
+{
+ [Hello say:@"hello"];
+ return 0;
+}
diff --git a/tests/projects/objc/modulemap/src/module.modulemap b/tests/projects/objc/modulemap/src/module.modulemap
new file mode 100644
index 000000000..91a9c4235
--- /dev/null
+++ b/tests/projects/objc/modulemap/src/module.modulemap
@@ -0,0 +1,4 @@
+module Hello {
+ header "hello.h"
+ export *
+}
diff --git a/tests/projects/objc/modulemap/xmake.lua b/tests/projects/objc/modulemap/xmake.lua
new file mode 100644
index 000000000..db00678f2
--- /dev/null
+++ b/tests/projects/objc/modulemap/xmake.lua
@@ -0,0 +1,6 @@
+target("modulemap")
+ set_kind("binary")
+ add_files("src/*.m")
+ add_mflags("-fmodules", "-fmodule-map-file=src/module.modulemap")
+
+
diff --git a/tests/projects/swift/modulemap/src/hello.cpp b/tests/projects/swift/modulemap/src/hello.cpp
new file mode 100644
index 000000000..42b01afac
--- /dev/null
+++ b/tests/projects/swift/modulemap/src/hello.cpp
@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include "hello.h"
+
+void say1(char const* s) {
+ printf("%s\n", s);
+}
+
+
diff --git a/tests/projects/swift/modulemap/src/hello.h b/tests/projects/swift/modulemap/src/hello.h
new file mode 100644
index 000000000..80849f5df
--- /dev/null
+++ b/tests/projects/swift/modulemap/src/hello.h
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void say1(char const* s);
+#ifdef __cplusplus
+}
+#endif
+static inline void say2(char const* s) {
+ printf("%s\n", s);
+}
+
+
diff --git a/tests/projects/swift/modulemap/src/main.swift b/tests/projects/swift/modulemap/src/main.swift
new file mode 100644
index 000000000..0cc015090
--- /dev/null
+++ b/tests/projects/swift/modulemap/src/main.swift
@@ -0,0 +1,5 @@
+import Foundation
+import hello
+
+hello.say1("hello1")
+hello.say2("hello2")
diff --git a/tests/projects/swift/modulemap/src/module.modulemap b/tests/projects/swift/modulemap/src/module.modulemap
new file mode 100644
index 000000000..69c787ee2
--- /dev/null
+++ b/tests/projects/swift/modulemap/src/module.modulemap
@@ -0,0 +1,4 @@
+module hello {
+ header "hello.h"
+ export *
+}
diff --git a/tests/projects/swift/modulemap/xmake.lua b/tests/projects/swift/modulemap/xmake.lua
new file mode 100644
index 000000000..fb329e99e
--- /dev/null
+++ b/tests/projects/swift/modulemap/xmake.lua
@@ -0,0 +1,4 @@
+target("modulemap")
+ set_kind("binary")
+ add_files("src/*.swift", "src/*.cpp")
+ add_scflags("-Xcc -fmodules", "-Xcc -fmodule-map-file=src/module.modulemap")