Skip to content

Commit 712457d

Browse files
committed
[Test] Add executable tests for non-matching error/result values in direct error return typed throws
1 parent 8d7eba1 commit 712457d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

test/Interpreter/Inputs/typed_throws_abi_impl.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ public struct Impl: P {
8888
}
8989
return (1, 2, 3, 4, 5)
9090
}
91+
92+
public func nonMatching_f0(_ b: Bool) throws(OneWord) -> (Float, Float) {
93+
guard b else {
94+
throw OneWord()
95+
}
96+
return (1.0, 2.0)
97+
}
98+
99+
public func nonMatching_f1(_ b: Bool) throws(OneWord) -> (Float, Bool, Float) {
100+
guard b else {
101+
throw OneWord()
102+
}
103+
return (1.0, true, 2.0)
104+
}
91105
}
92106

93107
@available(SwiftStdlib 6.0, *)
@@ -175,6 +189,20 @@ public struct ImplAsync: PAsync {
175189
}
176190
return (1, 2, 3, 4, 5)
177191
}
192+
193+
public func nonMatching_f0(_ b: Bool) async throws(OneWord) -> (Float, Float) {
194+
guard b else {
195+
throw OneWord()
196+
}
197+
return (1.0, 2.0)
198+
}
199+
200+
public func nonMatching_f1(_ b: Bool) async throws(OneWord) -> (Float, Bool, Float) {
201+
guard b else {
202+
throw OneWord()
203+
}
204+
return (1.0, true, 2.0)
205+
}
178206
}
179207

180208
public protocol P {
@@ -191,6 +219,9 @@ public protocol P {
191219
func g3(_ b: Bool) throws(OneWord) -> (Int, Int, Int)
192220
func g4(_ b: Bool) throws(OneWord) -> (Int, Int, Int, Int)
193221
func g5(_ b: Bool) throws(OneWord) -> (Int, Int, Int, Int, Int)
222+
223+
func nonMatching_f0(_ b: Bool) throws(OneWord) -> (Float, Float)
224+
func nonMatching_f1(_ b: Bool) throws(OneWord) -> (Float, Bool, Float)
194225
}
195226

196227
@available(SwiftStdlib 6.0, *)
@@ -208,4 +239,7 @@ public protocol PAsync {
208239
func g3(_ b: Bool) async throws(OneWord) -> (Int, Int, Int)
209240
func g4(_ b: Bool) async throws(OneWord) -> (Int, Int, Int, Int)
210241
func g5(_ b: Bool) async throws(OneWord) -> (Int, Int, Int, Int, Int)
242+
243+
func nonMatching_f0(_ b: Bool) async throws(OneWord) -> (Float, Float)
244+
func nonMatching_f1(_ b: Bool) async throws(OneWord) -> (Float, Bool, Float)
211245
}

test/Interpreter/typed_throws_abi.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ func checkSync() async {
7777
await invoke { try impl.g5(true) }
7878
// CHECK: Error: OneWord(x: 0)
7979
await invoke { try impl.g5(false) }
80+
81+
// CHECK: Success: (1.0, 2.0)
82+
await invoke { try impl.nonMatching_f0(true) }
83+
// CHECK: Error: OneWord(x: 0)
84+
await invoke { try impl.nonMatching_f0(false) }
85+
86+
// CHECK: Success: (1.0, true, 2.0)
87+
await invoke { try impl.nonMatching_f1(true) }
88+
// CHECK: Error: OneWord(x: 0)
89+
await invoke { try impl.nonMatching_f1(false) }
8090
}
8191

8292
func checkAsync() async {
@@ -140,6 +150,16 @@ func checkAsync() async {
140150
await invoke { try await impl.g5(true) }
141151
// CHECK: Error: OneWord(x: 0)
142152
await invoke { try await impl.g5(false) }
153+
154+
// CHECK: Success: (1.0, 2.0)
155+
await invoke { try await impl.nonMatching_f0(true) }
156+
// CHECK: Error: OneWord(x: 0)
157+
await invoke { try await impl.nonMatching_f0(false) }
158+
159+
// CHECK: Success: (1.0, true, 2.0)
160+
await invoke { try await impl.nonMatching_f1(true) }
161+
// CHECK: Error: OneWord(x: 0)
162+
await invoke { try await impl.nonMatching_f1(false) }
143163
}
144164

145165
@main

0 commit comments

Comments
 (0)