Commit 7b0e0d2 1 parent 85e1a11 commit 7b0e0d2 Copy full SHA for 7b0e0d2
File tree 2 files changed +23
-1
lines changed
IntegrationTests/TestSuites/Sources/PrimaryTests
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -804,5 +804,27 @@ try test("Hashable Conformance") {
804
804
try expectEqual ( firstHash, secondHash)
805
805
}
806
806
807
+ struct AnimalStruct : Decodable {
808
+ let name : String
809
+ let age : Int
810
+ let isCat : Bool
811
+ }
812
+
813
+ try test ( " JSValueDecoder " ) {
814
+ let Animal = JSObject . global. Animal. function!
815
+ let tama = try Animal . throws. new ( " Tama " , 3 , true )
816
+ let decoder = JSValueDecoder ( )
817
+ let decodedTama = try decoder. decode ( AnimalStruct . self, from: tama. jsValue)
818
+
819
+ try expectEqual ( decodedTama. name, tama. name. string)
820
+ try expectEqual ( decodedTama. name, " Tama " )
821
+
822
+ try expectEqual ( decodedTama. age, tama. age. number. map ( Int . init) )
823
+ try expectEqual ( decodedTama. age, 3 )
824
+
825
+ try expectEqual ( decodedTama. isCat, tama. isCat. boolean)
826
+ try expectEqual ( decodedTama. isCat, true )
827
+ }
828
+
807
829
808
830
Expectation . wait ( expectations)
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ private struct _Decoder: Decoder {
34
34
}
35
35
36
36
private enum Object {
37
- static let ref = JSObject . global. Object. object !
37
+ static let ref = JSObject . global. Object. function !
38
38
static func keys( _ object: JSObject ) -> [ String ] {
39
39
let keys = ref. keys!( object) . array!
40
40
return keys. map { $0. string! }
You can’t perform that action at this time.
0 commit comments