File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ impl<'a> DocumentBuilder<'a> {
165
165
// Int
166
166
0 => InputValue :: Int ( self . u . arbitrary ( ) ?) ,
167
167
// Float
168
- 1 => InputValue :: Float ( self . u . arbitrary ( ) ?) ,
168
+ 1 => InputValue :: Float ( self . finite_f64 ( ) ?) ,
169
169
// String
170
170
2 => InputValue :: String ( self . limited_string ( 40 ) ?) ,
171
171
// Boolean
@@ -211,7 +211,7 @@ impl<'a> DocumentBuilder<'a> {
211
211
match ty. name ( ) . name . as_str ( ) {
212
212
"String" => Ok ( InputValue :: String ( doc_builder. limited_string ( 1000 ) ?) ) ,
213
213
"Int" => Ok ( InputValue :: Int ( doc_builder. u . arbitrary ( ) ?) ) ,
214
- "Float" => Ok ( InputValue :: Float ( doc_builder. u . arbitrary ( ) ?) ) ,
214
+ "Float" => Ok ( InputValue :: Float ( doc_builder. finite_f64 ( ) ?) ) ,
215
215
"Boolean" => Ok ( InputValue :: Boolean ( doc_builder. u . arbitrary ( ) ?) ) ,
216
216
"ID" => Ok ( InputValue :: Int ( doc_builder. u . arbitrary ( ) ?) ) ,
217
217
other => {
@@ -329,6 +329,15 @@ impl<'a> DocumentBuilder<'a> {
329
329
directives,
330
330
} )
331
331
}
332
+
333
+ fn finite_f64 ( & mut self ) -> arbitrary:: Result < f64 > {
334
+ loop {
335
+ let val: f64 = self . u . arbitrary ( ) ?;
336
+ if val. is_finite ( ) {
337
+ return Ok ( val) ;
338
+ }
339
+ }
340
+ }
332
341
}
333
342
334
343
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments