Skip to content

Commit 2c48c62

Browse files
committed
[interp] support nfloat.*Infinity
1 parent 5c5a48b commit 2c48c62

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed

mono/mini/builtin-types.cs

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,10 +1025,94 @@ static int test_0_nfloat_cmp_right_nan ()
10251025
return 0;
10261026
}
10271027

1028+
static int test_0_nfloat_isinfinity ()
1029+
{
1030+
var x = (nfloat) float.NaN;
1031+
if (nfloat.IsInfinity (x))
1032+
return 1;
1033+
if (nfloat.IsInfinity (12))
1034+
return 2;
1035+
if (!nfloat.IsInfinity (nfloat.PositiveInfinity))
1036+
return 3;
1037+
if (!nfloat.IsInfinity (nfloat.NegativeInfinity))
1038+
return 4;
1039+
1040+
return 0;
1041+
}
1042+
1043+
static int test_0_nfloat_isnegativeinfinity ()
1044+
{
1045+
var x = (nfloat) float.NaN;
1046+
if (nfloat.IsNegativeInfinity (x))
1047+
return 1;
1048+
if (nfloat.IsNegativeInfinity (12))
1049+
return 2;
1050+
if (nfloat.IsNegativeInfinity (nfloat.PositiveInfinity))
1051+
return 3;
1052+
if (!nfloat.IsNegativeInfinity (nfloat.NegativeInfinity))
1053+
return 4;
1054+
1055+
float f = float.NegativeInfinity;
1056+
nfloat n = (nfloat) f;
1057+
if (!nfloat.IsNegativeInfinity (n))
1058+
return 5;
1059+
1060+
double d = double.NegativeInfinity;
1061+
n = (nfloat) d;
1062+
if (!nfloat.IsNegativeInfinity (n))
1063+
return 6;
1064+
1065+
return 0;
1066+
}
1067+
1068+
static int test_0_nfloat_ispositiveinfinity ()
1069+
{
1070+
var x = (nfloat) float.NaN;
1071+
if (nfloat.IsPositiveInfinity (x))
1072+
return 1;
1073+
if (nfloat.IsPositiveInfinity (12))
1074+
return 2;
1075+
if (!nfloat.IsPositiveInfinity (nfloat.PositiveInfinity))
1076+
return 3;
1077+
if (nfloat.IsPositiveInfinity (nfloat.NegativeInfinity))
1078+
return 4;
1079+
1080+
float f = float.PositiveInfinity;
1081+
nfloat n = (nfloat) f;
1082+
if (!nfloat.IsPositiveInfinity (n))
1083+
return 5;
1084+
1085+
double d = double.PositiveInfinity;
1086+
n = (nfloat) d;
1087+
if (!nfloat.IsPositiveInfinity (n))
1088+
return 6;
1089+
1090+
return 0;
1091+
}
1092+
10281093
static int test_0_nfloat_isnan ()
10291094
{
10301095
var x = (nfloat) float.NaN;
1031-
return nfloat.IsNaN (x) ? 0 : 1;
1096+
if (!nfloat.IsNaN (x))
1097+
return 1;
1098+
if (nfloat.IsNaN (12))
1099+
return 2;
1100+
if (nfloat.IsNaN (nfloat.PositiveInfinity))
1101+
return 3;
1102+
if (nfloat.IsNaN (nfloat.NegativeInfinity))
1103+
return 4;
1104+
1105+
float f = float.NaN;
1106+
nfloat n = (nfloat) f;
1107+
if (!nfloat.IsNaN (n))
1108+
return 5;
1109+
1110+
double d = double.NaN;
1111+
n = (nfloat) d;
1112+
if (!nfloat.IsNaN (n))
1113+
return 6;
1114+
1115+
return 0;
10321116
}
10331117

10341118
static int test_0_nfloat_compareto ()

mono/mini/interp/transform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoMeth
10671067
} else if (!strcmp ("Parse", tm)) {
10681068
/* white list */
10691069
return FALSE;
1070-
} else if (!strcmp ("IsNaN", tm)) {
1070+
} else if (!strcmp ("IsNaN", tm) || !strcmp ("IsInfinity", tm) || !strcmp ("IsNegativeInfinity", tm) || !strcmp ("IsPositiveInfinity", tm)) {
10711071
g_assert (type_index == 2); // nfloat only
10721072
/* white list */
10731073
return FALSE;

0 commit comments

Comments
 (0)