File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ fn value_bool() {
24
24
25
25
#[ test]
26
26
fn value_number ( ) {
27
+ #[ cfg( all( not( feature = "arbitrary_precision" ) , feature = "std" ) ) ]
28
+ assert_eq ! ( format!( "{:?}" , json!( :: std:: f64 :: NAN ) ) , "Number(NaN)" ) ;
29
+
27
30
assert_eq ! ( format!( "{:?}" , json!( 1 ) ) , "Number(1)" ) ;
28
31
assert_eq ! ( format!( "{:?}" , json!( -1 ) ) , "Number(-1)" ) ;
29
32
assert_eq ! ( format!( "{:?}" , json!( 1.0 ) ) , "Number(1.0)" ) ;
Original file line number Diff line number Diff line change @@ -161,13 +161,21 @@ fn test_write_f64() {
161
161
#[ test]
162
162
fn test_encode_nonfinite_float_yields_null ( ) {
163
163
let v = to_value ( :: std:: f64:: NAN ) . unwrap ( ) ;
164
- assert ! ( v. is_null( ) ) ;
164
+ if !cfg ! ( feature = "arbitrary_precision" ) && cfg ! ( feature = "std" ) {
165
+ assert ! ( v. is_f64( ) ) ;
166
+ } else {
167
+ assert ! ( v. is_null( ) ) ;
168
+ }
165
169
166
170
let v = to_value ( :: std:: f64:: INFINITY ) . unwrap ( ) ;
167
171
assert ! ( v. is_null( ) ) ;
168
172
169
173
let v = to_value ( :: std:: f32:: NAN ) . unwrap ( ) ;
170
- assert ! ( v. is_null( ) ) ;
174
+ if !cfg ! ( feature = "arbitrary_precision" ) && cfg ! ( feature = "std" ) {
175
+ assert ! ( v. is_f64( ) ) ;
176
+ } else {
177
+ assert ! ( v. is_null( ) ) ;
178
+ }
171
179
172
180
let v = to_value ( :: std:: f32:: INFINITY ) . unwrap ( ) ;
173
181
assert ! ( v. is_null( ) ) ;
@@ -693,6 +701,17 @@ fn test_parse_null() {
693
701
test_parse_ok ( vec ! [ ( "null" , ( ) ) ] ) ;
694
702
}
695
703
704
+ #[ test]
705
+ fn test_parse_nan ( ) {
706
+ test_parse_err :: < ( ) > ( & [
707
+ ( "n" , "EOF while parsing a value at line 1 column 1" ) ,
708
+ ( "na" , "expected ident at line 1 column 2" ) ,
709
+ ( "nana" , "expected ident at line 1 column 2" ) ,
710
+ ] ) ;
711
+
712
+ assert ! ( from_str:: <f64 >( "nan" ) . unwrap( ) . is_nan( ) ) ;
713
+ }
714
+
696
715
#[ test]
697
716
fn test_parse_bool ( ) {
698
717
test_parse_err :: < bool > ( & [
You can’t perform that action at this time.
0 commit comments