@@ -86,11 +86,10 @@ impl Display for Type {
86
86
Type :: String => write ! ( f, "String" ) ,
87
87
Type :: BNum => write ! ( f, "BNum" ) ,
88
88
Type :: Bool => write ! ( f, "Bool" ) ,
89
- // TODO: Fix map type
90
- Type :: Map ( ref k, ref v) => write ! ( f, "MapType ({}, {})" , k, v) ,
91
- Type :: Option ( ref k) => write ! ( f, "Option ({})" , k) ,
92
- Type :: List ( ref k) => write ! ( f, "List ({})" , k) ,
93
- Type :: Pair ( ref k, ref v) => write ! ( f, "Pair ({}, {})" , k, v) ,
89
+ Type :: Map ( ref k, ref v) => write ! ( f, "(Map {}, {})" , k, v) ,
90
+ Type :: Option ( ref k) => write ! ( f, "(Option {})" , k) ,
91
+ Type :: List ( ref k) => write ! ( f, "(List {})" , k) ,
92
+ Type :: Pair ( ref k, ref v) => write ! ( f, "(Pair {} {})" , k, v) ,
94
93
Type :: ByStr ( n) => write ! ( f, "ByStr{}" , n) ,
95
94
Type :: Other ( ref s) => write ! ( f, "{}" , s) ,
96
95
}
@@ -155,4 +154,38 @@ mod tests {
155
154
156
155
assert_eq ! ( option_bool_type, Type :: Option ( Box :: new( Type :: Bool ) ) ) ;
157
156
}
157
+
158
+ #[ test]
159
+ fn test_type_to_string ( ) {
160
+ //(List (Pair ByStr20 (List (Pair ByStr20 Uint32))))
161
+ let list_type = Type :: List ( Box :: new ( Type :: Pair (
162
+ Box :: new ( Type :: ByStr ( 20 ) ) ,
163
+ Box :: new ( Type :: List ( Box :: new ( Type :: Pair (
164
+ Box :: new ( Type :: ByStr ( 20 ) ) ,
165
+ Box :: new ( Type :: Uint32 ) ,
166
+ ) ) ) ) ,
167
+ ) ) ) ;
168
+
169
+ assert_eq ! (
170
+ "(List (Pair ByStr20 (List (Pair ByStr20 Uint32))))" ,
171
+ list_type. to_string( )
172
+ ) ;
173
+
174
+ // (List (Pair ByStr20 (List (Pair ByStr20 (List (Pair Uint32 Uint128))))))
175
+ let list_type = Type :: List ( Box :: new ( Type :: Pair (
176
+ Box :: new ( Type :: ByStr ( 20 ) ) ,
177
+ Box :: new ( Type :: List ( Box :: new ( Type :: Pair (
178
+ Box :: new ( Type :: ByStr ( 20 ) ) ,
179
+ Box :: new ( Type :: List ( Box :: new ( Type :: Pair (
180
+ Box :: new ( Type :: Uint32 ) ,
181
+ Box :: new ( Type :: Uint128 ) ,
182
+ ) ) ) ) ,
183
+ ) ) ) ) ,
184
+ ) ) ) ;
185
+
186
+ assert_eq ! (
187
+ "(List (Pair ByStr20 (List (Pair ByStr20 (List (Pair Uint32 Uint128))))))" ,
188
+ list_type. to_string( )
189
+ ) ;
190
+ }
158
191
}
0 commit comments