File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -691,14 +691,17 @@ struct TestConstants {
691691
692692const globalInt :UInt32 = 12345;
693693
694- struct TestNonFiniteFloatConsts {
694+ struct TestFloatConsts {
695695 const a :Float32 = inf;
696696 const b :Float32 = -inf;
697697 const c :Float32 = nan;
698698
699699 const x :Float64 = inf;
700700 const y :Float64 = -inf;
701701 const z :Float64 = nan;
702+
703+ const pi32 : Float32 = 3. 14159265358979323846264338327950288;
704+ const pi64 : Float64 = 3. 14159265358979323846264338327950288;
702705}
703706
704707interface TestInterface {
Original file line number Diff line number Diff line change @@ -1201,6 +1201,30 @@ mod tests {
12011201 assert_eq ! ( struct_list. get( 2 ) . get_text_field( ) . unwrap( ) , "structlist 3" ) ;
12021202 }
12031203
1204+ #[ test]
1205+ fn test_float_constants ( ) {
1206+ use crate :: test_capnp:: test_float_consts;
1207+
1208+ assert ! ( test_float_consts:: A . is_infinite( ) ) ;
1209+ assert ! ( test_float_consts:: A . is_sign_positive( ) ) ;
1210+
1211+ assert ! ( test_float_consts:: B . is_infinite( ) ) ;
1212+ assert ! ( test_float_consts:: B . is_sign_negative( ) ) ;
1213+
1214+ assert ! ( test_float_consts:: C . is_nan( ) ) ;
1215+
1216+ assert ! ( test_float_consts:: X . is_infinite( ) ) ;
1217+ assert ! ( test_float_consts:: X . is_sign_positive( ) ) ;
1218+
1219+ assert ! ( test_float_consts:: Y . is_infinite( ) ) ;
1220+ assert ! ( test_float_consts:: Y . is_sign_negative( ) ) ;
1221+
1222+ assert ! ( test_float_consts:: Z . is_nan( ) ) ;
1223+
1224+ assert_eq ! ( test_float_consts:: PI32 , std:: f32 :: consts:: PI ) ;
1225+ assert_eq ! ( test_float_consts:: PI64 , std:: f64 :: consts:: PI ) ;
1226+ }
1227+
12041228 #[ test]
12051229 fn test_set_root ( ) {
12061230 use crate :: test_capnp:: test_big_struct;
You can’t perform that action at this time.
0 commit comments