@@ -127,6 +127,82 @@ describe("argumentTypes", () => {
127
127
} ) ;
128
128
} ) ;
129
129
130
+ describe ( "bigint type" , ( ) => {
131
+ it ( "should work with decimal values" , ( ) => {
132
+ assert . equal ( types . bigint . parse ( "arg" , "0" ) , 0n ) ;
133
+ assert . equal ( types . bigint . parse ( "arg" , "1" ) , 1n ) ;
134
+ assert . equal ( types . bigint . parse ( "arg" , "1123" ) , 1123n ) ;
135
+ assert . equal ( types . bigint . parse ( "arg" , "05678" ) , 5678n ) ;
136
+ assert . equal (
137
+ types . bigint . parse ( "arg" , "9007199254740992" ) ,
138
+ BigInt ( "9007199254740992" )
139
+ ) ;
140
+ } ) ;
141
+
142
+ it ( "should work with hex values" , ( ) => {
143
+ assert . equal ( types . bigint . parse ( "arg" , "0x0" ) , BigInt ( 0 ) ) ;
144
+ assert . equal ( types . bigint . parse ( "arg" , "0x1" ) , BigInt ( 1 ) ) ;
145
+ assert . equal ( types . bigint . parse ( "arg" , "0xA" ) , BigInt ( 0xa ) ) ;
146
+ assert . equal ( types . bigint . parse ( "arg" , "0xa" ) , BigInt ( 0xa ) ) ;
147
+ assert . equal ( types . bigint . parse ( "arg" , "0x0a" ) , BigInt ( 0x0a ) ) ;
148
+ assert . equal (
149
+ types . bigint . parse ( "arg" , "0x20000000000000" ) ,
150
+ BigInt ( "0x20000000000000" )
151
+ ) ;
152
+ } ) ;
153
+
154
+ it ( "should work with bigint values with 'n' suffix" , ( ) => {
155
+ assert . equal ( types . bigint . parse ( "arg" , "0n" ) , BigInt ( 0 ) ) ;
156
+ } ) ;
157
+
158
+ it ( "should fail with incorrect values" , ( ) => {
159
+ expectHardhatError (
160
+ ( ) => types . bigint . parse ( "arg" , "" ) ,
161
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
162
+ ) ;
163
+ expectHardhatError (
164
+ ( ) => types . bigint . parse ( "arg" , "1." ) ,
165
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
166
+ ) ;
167
+ expectHardhatError (
168
+ ( ) => types . bigint . parse ( "arg" , ".1" ) ,
169
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
170
+ ) ;
171
+ expectHardhatError (
172
+ ( ) => types . bigint . parse ( "arg" , "0.1" ) ,
173
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
174
+ ) ;
175
+ expectHardhatError (
176
+ ( ) => types . bigint . parse ( "arg" , "asdas" ) ,
177
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
178
+ ) ;
179
+ expectHardhatError (
180
+ ( ) => types . bigint . parse ( "arg" , "a1" ) ,
181
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
182
+ ) ;
183
+ expectHardhatError (
184
+ ( ) => types . bigint . parse ( "arg" , "1a" ) ,
185
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
186
+ ) ;
187
+ expectHardhatError (
188
+ ( ) => types . bigint . parse ( "arg" , "1 1" ) ,
189
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
190
+ ) ;
191
+ expectHardhatError (
192
+ ( ) => types . bigint . parse ( "arg" , "x123" ) ,
193
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
194
+ ) ;
195
+ expectHardhatError (
196
+ ( ) => types . bigint . parse ( "arg" , "1e0" ) ,
197
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
198
+ ) ;
199
+ expectHardhatError (
200
+ ( ) => types . bigint . parse ( "arg" , "0x0n" ) ,
201
+ ERRORS . ARGUMENTS . INVALID_VALUE_FOR_TYPE
202
+ ) ;
203
+ } ) ;
204
+ } ) ;
205
+
130
206
describe ( "float type" , ( ) => {
131
207
it ( "should work with integer decimal values" , ( ) => {
132
208
assert . equal ( types . float . parse ( "arg" , "0" ) , 0 ) ;
0 commit comments