From 1d6857de2bc044f45f76270256fad011a591abfc Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 7 Sep 2019 00:49:30 +0800 Subject: add modulemap tests --- .../c++/modules/modulemap.modulemap/src/hello.h | 18 ------------------ .../c++/modules/modulemap.modulemap/src/main.cpp | 9 --------- .../modules/modulemap.modulemap/src/module.modulemap | 4 ---- .../projects/c++/modules/modulemap.modulemap/xmake.lua | 6 ------ tests/projects/objc++/modulemap/src/hello.h | 7 +++++++ tests/projects/objc++/modulemap/src/hello.m | 10 ++++++++++ tests/projects/objc++/modulemap/src/main.mm | 8 ++++++++ tests/projects/objc++/modulemap/src/module.modulemap | 4 ++++ tests/projects/objc++/modulemap/xmake.lua | 6 ++++++ tests/projects/objc/modulemap/src/hello.h | 7 +++++++ tests/projects/objc/modulemap/src/hello.m | 10 ++++++++++ tests/projects/objc/modulemap/src/main.m | 8 ++++++++ tests/projects/objc/modulemap/src/module.modulemap | 4 ++++ tests/projects/objc/modulemap/xmake.lua | 6 ++++++ tests/projects/swift/modulemap/src/hello.cpp | 8 ++++++++ tests/projects/swift/modulemap/src/hello.h | 14 ++++++++++++++ tests/projects/swift/modulemap/src/main.swift | 5 +++++ tests/projects/swift/modulemap/src/module.modulemap | 4 ++++ tests/projects/swift/modulemap/xmake.lua | 4 ++++ 19 files changed, 105 insertions(+), 37 deletions(-) delete mode 100644 tests/projects/c++/modules/modulemap.modulemap/src/hello.h delete mode 100644 tests/projects/c++/modules/modulemap.modulemap/src/main.cpp delete mode 100644 tests/projects/c++/modules/modulemap.modulemap/src/module.modulemap delete mode 100644 tests/projects/c++/modules/modulemap.modulemap/xmake.lua create mode 100644 tests/projects/objc++/modulemap/src/hello.h create mode 100644 tests/projects/objc++/modulemap/src/hello.m create mode 100644 tests/projects/objc++/modulemap/src/main.mm create mode 100644 tests/projects/objc++/modulemap/src/module.modulemap create mode 100644 tests/projects/objc++/modulemap/xmake.lua create mode 100644 tests/projects/objc/modulemap/src/hello.h create mode 100644 tests/projects/objc/modulemap/src/hello.m create mode 100644 tests/projects/objc/modulemap/src/main.m create mode 100644 tests/projects/objc/modulemap/src/module.modulemap create mode 100644 tests/projects/objc/modulemap/xmake.lua create mode 100644 tests/projects/swift/modulemap/src/hello.cpp create mode 100644 tests/projects/swift/modulemap/src/hello.h create mode 100644 tests/projects/swift/modulemap/src/main.swift create mode 100644 tests/projects/swift/modulemap/src/module.modulemap create mode 100644 tests/projects/swift/modulemap/xmake.lua 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/src/module.modulemap b/tests/projects/c++/modules/modulemap.modulemap/src/module.modulemap deleted file mode 100644 index 69c787ee2..000000000 --- a/tests/projects/c++/modules/modulemap.modulemap/src/module.modulemap +++ /dev/null @@ -1,4 +0,0 @@ -module hello { - header "hello.h" - export * -} 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 + +@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 +@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 + +@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 +@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 +#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 + +#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") -- cgit v1.3.1