File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ // Expanding macros that are defined in terms of other macros.
2+
3+ // RUN: %empty-directory(%t)
4+ // RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -parse-as-library -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
5+
6+ // Diagnostics testing
7+ // RUN: %target-typecheck-verify-swift -swift-version 5 -enable-experimental-feature FreestandingMacros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir -module-name MacroUser -DTEST_DIAGNOSTICS
8+
9+ // Execution testing
10+ // RUN: %target-build-swift -swift-version 5 -enable-experimental-feature FreestandingMacros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir -L %swift-host-lib-dir %s -o %t/main -module-name MacroUser
11+ // RUN: %target-run %t/main | %FileCheck %s
12+ // RUN: %target-codesign %t/main
13+ // REQUIRES: swift_swift_parser, executable_test
14+
15+ @freestanding ( expression) macro stringify< T> ( _ value: T ) -> ( T , String ) = #externalMacro( module: " MacroDefinition " , type: " StringifyMacro " )
16+
17+ @freestanding ( expression) macro stringifySeven( ) -> ( Int , String ) = #stringify ( 7 )
18+
19+ @freestanding ( expression) macro recurse( _: Bool ) = #externalMacro( module: " MacroDefinition " , type: " RecursiveMacro " )
20+
21+ @freestanding ( expression) macro recurseThrough( _ value: Bool ) = #recurse( value)
22+
23+ func testFreestandingExpansionOfOther( ) {
24+ // CHECK: ---testFreestandingExpansionOfOther
25+ print ( " ---testFreestandingExpansionOfOther " )
26+
27+ // CHECK-NEXT: (7, "7")
28+ print ( #stringifySeven)
29+
30+ #recurseThrough( false )
31+
32+ #if TEST_DIAGNOSTICS
33+ #recurseThrough( true )
34+ // expected-note@-1 2{{in expansion of macro 'recurseThrough' here}}
35+ #endif
36+ }
37+
38+ testFreestandingExpansionOfOther ( )
You can’t perform that action at this time.
0 commit comments