-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathsyntactic_expansion.swift
82 lines (70 loc) · 2.42 KB
/
syntactic_expansion.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//--- test.swift
@DelegatedConformance
@wrapAllProperties
struct Generic<Element> {
@myPropertyWrapper
@otherAttr
var value: Int
func member() {}
var otherVal: Int = 1
#bitwidthNumberedStructs("blah")
}
//--- DelegatedConformance.json
{
key.macro_roles: [source.lang.swift.macro_role.conformance, source.lang.swift.macro_role.member],
key.modulename: "MacroDefinition",
key.typename: "DelegatedConformanceMacro",
}
//--- myPropertyWrapper.json
{
key.macro_roles: [source.lang.swift.macro_role.accessor, source.lang.swift.macro_role.peer],
key.modulename: "MacroDefinition",
key.typename: "PropertyWrapperMacro",
}
//--- wrapAllProperties.json
{
key.macro_roles: [source.lang.swift.macro_role.member_attribute],
key.modulename: "MacroDefinition",
key.typename: "WrapAllProperties",
}
//--- bitwidthNumberedStructs.json
{
key.macro_roles: [source.lang.swift.macro_role.declaration],
key.modulename: "MacroDefinition",
key.typename: "DefineBitwidthNumberedStructsMacro",
}
//--- dummy.script
// REQUIRES: swift_swift_parser
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/plugins
// RUN: split-file %s %t
//##-- Prepare the macro plugin.
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/plugins/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/../../Macros/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
// RUN: %sourcekitd-test \
// RUN: -shell -- echo '### 1' \
// RUN: == \
// RUN: -req=syntactic-expandmacro \
// RUN: -req-opts=1:1:%t/DelegatedConformance.json \
// RUN: -req-opts=5:3:%t/myPropertyWrapper.json \
// RUN: -req-opts=2:1:%t/wrapAllProperties.json \
// RUN: -req-opts=12:3:%t/bitwidthNumberedStructs.json \
// RUN: %t/test.swift \
// RUN: -- \
// RUN: %t/test.swift \
// RUN: -plugin-path %t/plugins -Xfrontend -dump-macro-expansions \
// RUN: -module-name TestModule \
// RUN: == \
// RUN: -shell -- echo '### 2' \
// RUN: == \
// RUN: -req=syntactic-expandmacro \
// RUN: -req-opts=12:3:%t/bitwidthNumberedStructs.json \
// RUN: -req-opts=2:1:%t/wrapAllProperties.json \
// RUN: -req-opts=5:3:%t/myPropertyWrapper.json \
// RUN: -req-opts=1:1:%t/DelegatedConformance.json \
// RUN: %t/test.swift \
// RUN: -- \
// RUN: %t/test.swift \
// RUN: -plugin-path %t/plugins -Xfrontend -dump-macro-expansions \
// RUN: -module-name TestModule \
// RUN: | tee %t.response
// RUN: diff -u %s.expected %t.response