summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-09-07 00:49:30 +0800
committerruki <[email protected]>2019-09-06 22:57:05 +0800
commit1d6857de2bc044f45f76270256fad011a591abfc (patch)
tree2a028539f470eaee636744990e15c3c42b39edbd
parent0f7e7701f27eec0118930eddefba0d0ca3269d38 (diff)
add modulemap tests
-rw-r--r--tests/projects/c++/modules/modulemap.modulemap/src/hello.h18
-rw-r--r--tests/projects/c++/modules/modulemap.modulemap/src/main.cpp9
-rw-r--r--tests/projects/c++/modules/modulemap.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.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.modulemap (renamed from tests/projects/c++/modules/modulemap.modulemap/src/module.modulemap)0
-rw-r--r--tests/projects/swift/modulemap/xmake.lua4
18 files changed, 101 insertions, 33 deletions
diff --git a/tests/projects/c++/modules/modulemap.modulemap/src/hello.h b/tests/projects/c++/modules/modulemap.modulemap/src/hello.h
deleted file mode 100644
index 743934c26..000000000
--- a/tests/projects/c++/modules/modulemap.modulemap/src/hello.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-import std;
-using namespace std;
-
-namespace hello {
- inline void say_hi() {
- cout << "hello hi!" << endl;
- }
-
- inline void say_hello() {
- cout << "hello world!" << endl;
- }
-
- inline void say_xz() {
- cout << "hello xz!" << endl;
- }
-} \ No newline at end of file
diff --git a/tests/projects/c++/modules/modulemap.modulemap/src/main.cpp b/tests/projects/c++/modules/modulemap.modulemap/src/main.cpp
deleted file mode 100644
index 6fffc01f7..000000000
--- a/tests/projects/c++/modules/modulemap.modulemap/src/main.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// #include "hello.h"
-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/modulemap.modulemap/xmake.lua b/tests/projects/c++/modules/modulemap.modulemap/xmake.lua
deleted file mode 100644
index 979f7a22e..000000000
--- a/tests/projects/c++/modules/modulemap.modulemap/xmake.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-target("modulemap")
- set_kind("binary")
- add_files("src/*.cpp", "src/*.mpp")
- set_languages("c++20")
-
-
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/c++/modules/modulemap.modulemap/src/module.modulemap b/tests/projects/swift/modulemap/src/module.modulemap
index 69c787ee2..69c787ee2 100644
--- a/tests/projects/c++/modules/modulemap.modulemap/src/module.modulemap
+++ b/tests/projects/swift/modulemap/src/module.modulemap
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")