Skip to content

Commit 9814cd7

Browse files
authored
Merge pull request #9575 from augusto2112/cp-decoding-test
[lldb] Add test for Swift.DecodingError enum (#9115)
2 parents 2449073 + 2c5c0c7 commit 9814cd7

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
include Makefile.rules
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import os
6+
7+
8+
class TestCase(TestBase):
9+
@swiftTest
10+
@skipUnlessFoundation
11+
def test_swift_decoding_error(self):
12+
"""Regression test for Swift.DecodingError, a specific instance of a multipayload enum."""
13+
self.build()
14+
lldbutil.run_to_source_breakpoint(
15+
self, "break here", lldb.SBFileSpec("main.swift")
16+
)
17+
18+
substrs = [
19+
"(DecodingError) ", " = keyNotFound {",
20+
'debugDescription = "No value associated with key CodingKeys(stringValue: \\"number\\", intValue: nil)',
21+
]
22+
self.expect("frame variable error", substrs=substrs)
23+
self.expect("expression error", substrs=substrs)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Foundation
2+
3+
struct Payload: Decodable {
4+
var number: Int
5+
}
6+
7+
func main() {
8+
do {
9+
let data = Data(#"{"numero":23}"#.utf8)
10+
_ = try JSONDecoder().decode(Payload.self, from: data)
11+
} catch {
12+
print("break here")
13+
}
14+
}
15+
16+
main()

0 commit comments

Comments
 (0)