diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/SwiftMix/CMain.c | 13 | ||||
-rw-r--r-- | Tests/SwiftMix/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/SwiftMix/SwiftMain.swift | 20 |
3 files changed, 34 insertions, 0 deletions
diff --git a/Tests/SwiftMix/CMain.c b/Tests/SwiftMix/CMain.c index 519058e..b274322 100644 --- a/Tests/SwiftMix/CMain.c +++ b/Tests/SwiftMix/CMain.c @@ -1,3 +1,16 @@ +#if !defined(FOO) +# error "FOO not defined" +#endif +#if BAR != 3 +# error "FOO not defined to 3" +#endif +#if CCOND != 2 +# error "CCOND not defined to 2" +#endif +#if defined(SWIFTCOND) +# error "SWIFTCOND defined" +#endif + extern int ObjCMain(void); int main(void) { diff --git a/Tests/SwiftMix/CMakeLists.txt b/Tests/SwiftMix/CMakeLists.txt index 6d8e48b..e8b6521 100644 --- a/Tests/SwiftMix/CMakeLists.txt +++ b/Tests/SwiftMix/CMakeLists.txt @@ -4,3 +4,4 @@ project(SwiftMix C Swift) add_executable(SwiftMix CMain.c ObjCMain.m SwiftMain.swift ObjC-Swift.h) set_property(TARGET SwiftMix PROPERTY XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "ObjC-Swift.h") target_compile_options(SwiftMix PRIVATE "$<$<COMPILE_LANGUAGE:C>:-Werror=objc-method-access>") +target_compile_definitions(SwiftMix PRIVATE "$<IF:$<COMPILE_LANGUAGE:Swift>,SWIFTCOND,CCOND=2>" FOO BAR=3) diff --git a/Tests/SwiftMix/SwiftMain.swift b/Tests/SwiftMix/SwiftMain.swift index d9c8cd7..238059d 100644 --- a/Tests/SwiftMix/SwiftMain.swift +++ b/Tests/SwiftMix/SwiftMain.swift @@ -3,6 +3,26 @@ import Foundation @objc class SwiftMainClass : NSObject { @objc class func SwiftMain() -> Int32 { dump("Hello World!"); +#if FOO + dump("FOO defined"); +#else + fatalError("FOO not defined"); +#endif +#if BAR + dump("BAR defined"); +#else + fatalError("BAR not defined"); +#endif +#if CCOND + fatalError("CCOND defined"); +#else + dump("CCOND not defined"); +#endif +#if SWIFTCOND + dump("SWIFTCOND defined"); +#else + fatalError("SWIFTCOND not defined"); +#endif return 0; } } |