Skip to content

Commit c566db5

Browse files
[NFC] BridgeJS: Cover more types in closure snapshot tests
1 parent 180c010 commit c566db5

File tree

5 files changed

+2729
-1410
lines changed

5 files changed

+2729
-1410
lines changed

Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,34 @@ import JavaScriptKit
99
}
1010

1111
@JS class TestProcessor {
12-
private var transform: (String) -> String
13-
14-
@JS init(transform: @escaping (String) -> String) {
15-
self.transform = transform
16-
}
17-
18-
@JS func getTransform() -> (String) -> String
19-
20-
@JS func processWithCustom(_ text: String, customTransform: (String) -> String) -> String
12+
@JS init(transform: @escaping (String) -> String) {}
13+
}
2114

22-
@JS func printTogether(
23-
person: Person,
24-
name: String,
25-
ratio: Double,
26-
customTransform: (Person?, String?, Double?) -> String
27-
) -> String
15+
@JS func roundtripString(_ stringClosure: (String) -> String) -> (String) -> String
16+
@JS func roundtripInt(_ intClosure: (Int) -> Int) -> (Int) -> Int
17+
@JS func roundtripBool(_ boolClosure: (Bool) -> Bool) -> (Bool) -> Bool
18+
@JS func roundtripFloat(_ floatClosure: (Float) -> Float) -> (Float) -> Float
19+
@JS func roundtripDouble(_ doubleClosure: (Double) -> Double) -> (Double) -> Double
2820

29-
@JS func roundtrip(_ personClosure: (Person) -> String) -> (Person) -> String
30-
@JS func roundtripOptional(_ personClosure: (Person?) -> String) -> (Person?) -> String
21+
@JS func roundtripOptionalString(_ stringClosure: (String?) -> String?) -> (String?) -> String?
22+
@JS func roundtripOptionalInt(_ intClosure: (Int?) -> Int?) -> (Int?) -> Int?
23+
@JS func roundtripOptionalBool(_ boolClosure: (Bool?) -> Bool?) -> (Bool?) -> Bool?
24+
@JS func roundtripOptionalFloat(_ floatClosure: (Float?) -> Float?) -> (Float?) -> Float?
25+
@JS func roundtripOptionalDouble(_ doubleClosure: (Double?) -> Double?) -> (Double?) -> Double?
3126

32-
@JS func processDirection(_ callback: (Direction) -> String) -> String
33-
@JS func processTheme(_ callback: (Theme) -> String) -> String
34-
@JS func processHttpStatus(_ callback: (HttpStatus) -> Int) -> Int
35-
@JS func processAPIResult(_ callback: (APIResult) -> String) -> String
27+
@JS func roundtripPerson(_ personClosure: (Person) -> Person) -> (Person) -> Person
28+
@JS func roundtripOptionalPerson(_ personClosure: (Person?) -> Person?) -> (Person?) -> Person?
3629

37-
@JS func makeDirectionChecker() -> (Direction) -> Bool
38-
@JS func makeThemeValidator() -> (Theme) -> Bool
39-
@JS func makeStatusCodeExtractor() -> (HttpStatus) -> Int
40-
@JS func makeAPIResultHandler() -> (APIResult) -> String
30+
@JS func roundtripDirection(_ callback: (Direction) -> Direction) -> (Direction) -> Direction
31+
@JS func roundtripTheme(_ callback: (Theme) -> Theme) -> (Theme) -> Theme
32+
@JS func roundtripHttpStatus(_ callback: (HttpStatus) -> HttpStatus) -> (HttpStatus) -> HttpStatus
33+
@JS func roundtripAPIResult(_ callback: (APIResult) -> APIResult) -> (APIResult) -> APIResult
4134

42-
@JS func processOptionalDirection(_ callback: (Direction?) -> String) -> String
43-
@JS func processOptionalTheme(_ callback: (Theme?) -> String) -> String
44-
@JS func processOptionalAPIResult(_ callback: (APIResult?) -> String) -> String
45-
@JS func makeOptionalDirectionFormatter() -> (Direction?) -> String
46-
}
35+
@JS func roundtripOptionalDirection(_ callback: (Direction?) -> Direction?) -> (Direction?) -> Direction?
36+
@JS func roundtripOptionalTheme(_ callback: (Theme?) -> Theme?) -> (Theme?) -> Theme?
37+
@JS func roundtripOptionalHttpStatus(_ callback: (HttpStatus?) -> HttpStatus?) -> (HttpStatus?) -> HttpStatus?
38+
@JS func roundtripOptionalAPIResult(_ callback: (APIResult?) -> APIResult?) -> (APIResult?) -> APIResult?
39+
@JS func roundtripOptionalDirection(_ callback: (Direction?) -> Direction?) -> (Direction?) -> Direction?
4740

4841
@JS enum Direction {
4942
case north

0 commit comments

Comments
 (0)