@@ -19,13 +19,7 @@ impl TsConvert<TsRecordKey> for GtRecordKey {
1919 | GtRecordKey :: IntSize ( _)
2020 | GtRecordKey :: IntU64 ( _)
2121 | GtRecordKey :: IntU128 ( _)
22- | GtRecordKey :: IntUSize ( _) => {
23- // [TODO] Return an error instead of panicking. It is not
24- // straightforward because it will require changing `TsConvert`
25- // to return `Result`.
26- // See: https://github.com/kossnocorp/genotype/issues/8
27- panic ! ( "TypeScript records don't support BigInt as a key" )
28- }
22+ | GtRecordKey :: IntUSize ( _) => TsRecordKey :: String ,
2923 }
3024 }
3125}
@@ -41,13 +35,65 @@ mod tests {
4135 GtRecordKey :: String ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
4236 @"String"
4337 ) ;
38+ assert_ron_snapshot ! (
39+ GtRecordKey :: Number ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
40+ @"Number"
41+ ) ;
42+ assert_ron_snapshot ! (
43+ GtRecordKey :: Int8 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
44+ @"Number"
45+ ) ;
46+ assert_ron_snapshot ! (
47+ GtRecordKey :: Int16 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
48+ @"Number"
49+ ) ;
4450 assert_ron_snapshot ! (
4551 GtRecordKey :: Int32 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
4652 @"Number"
4753 ) ;
54+ assert_ron_snapshot ! (
55+ GtRecordKey :: IntU8 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
56+ @"Number"
57+ ) ;
58+ assert_ron_snapshot ! (
59+ GtRecordKey :: IntU16 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
60+ @"Number"
61+ ) ;
62+ assert_ron_snapshot ! (
63+ GtRecordKey :: IntU32 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
64+ @"Number"
65+ ) ;
66+ assert_ron_snapshot ! (
67+ GtRecordKey :: Float32 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
68+ @"Number"
69+ ) ;
4870 assert_ron_snapshot ! (
4971 GtRecordKey :: Float64 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
5072 @"Number"
5173 ) ;
74+ assert_ron_snapshot ! (
75+ GtRecordKey :: Int64 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
76+ @"String"
77+ ) ;
78+ assert_ron_snapshot ! (
79+ GtRecordKey :: Int128 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
80+ @"String"
81+ ) ;
82+ assert_ron_snapshot ! (
83+ GtRecordKey :: IntSize ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
84+ @"String"
85+ ) ;
86+ assert_ron_snapshot ! (
87+ GtRecordKey :: IntU64 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
88+ @"String"
89+ ) ;
90+ assert_ron_snapshot ! (
91+ GtRecordKey :: IntU128 ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
92+ @"String"
93+ ) ;
94+ assert_ron_snapshot ! (
95+ GtRecordKey :: IntUSize ( ( 0 , 0 ) . into( ) ) . convert( & mut Default :: default ( ) ) ,
96+ @"String"
97+ ) ;
5298 }
5399}
0 commit comments