Skip to content

Commit 62f23a8

Browse files
committed
[interp] support ntype.ToString ()
1 parent 2c48c62 commit 62f23a8

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

mono/mini/builtin-types.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,18 @@ static int test_0_nint_call_boxed_funs ()
301301
return 0;
302302
}
303303

304+
static int test_0_nint_tostring ()
305+
{
306+
int x = 1337;
307+
if (((nint) x).ToString () != "1337")
308+
return 1;
309+
x = -1337;
310+
if (((nint) x).ToString () != "-1337")
311+
return 2;
312+
313+
return 0;
314+
}
315+
304316
[MethodImplAttribute (MethodImplOptions.NoInlining)]
305317
static bool decimal_cmp (decimal a, decimal b)
306318
{
@@ -696,6 +708,18 @@ static int test_0_nuint_call_boxed_funs ()
696708
return 0;
697709
}
698710

711+
static int test_0_nuint_tostring ()
712+
{
713+
int x = 1337;
714+
if (((nuint) x).ToString () != "1337")
715+
return 1;
716+
x = -1337;
717+
if (((nuint) x).ToString () == "-1337")
718+
return 2;
719+
720+
return 0;
721+
}
722+
699723
static int test_0_nuint_implicit_decimal ()
700724
{
701725
nuint a = new nuint (10);
@@ -1168,6 +1192,19 @@ static int test_0_nfloat_call_boxed_funs ()
11681192
return 0;
11691193
}
11701194

1195+
static int test_0_nfloat_tostring ()
1196+
{
1197+
float x = 1337.0f;
1198+
nfloat y = (nfloat) x;
1199+
if (y.ToString () != "1337")
1200+
return 1;
1201+
x = -1337.0f;
1202+
if (((nfloat) x).ToString () != "-1337")
1203+
return 2;
1204+
1205+
return 0;
1206+
}
1207+
11711208
static int test_0_nfloat_explicit_decimal ()
11721209
{
11731210
nfloat a = new nfloat (10);

mono/mini/interp/transform.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,9 @@ 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 ("ToString", tm)) {
1071+
/* white list */
1072+
return FALSE;
10701073
} else if (!strcmp ("IsNaN", tm) || !strcmp ("IsInfinity", tm) || !strcmp ("IsNegativeInfinity", tm) || !strcmp ("IsPositiveInfinity", tm)) {
10711074
g_assert (type_index == 2); // nfloat only
10721075
/* white list */

0 commit comments

Comments
 (0)