[Tailcall] Bring coreclr tests for tail calls to Mono source tree (#7204)
[mono-project.git] / mono / tests / tailcall / coreclr / JIT / Methodical / Boxing / misc / tailjump.cs
blob24a3792b767ccad44a2c224d7ea5c78b05f412f3
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System;
7 namespace BoxTest
9 internal class Test
11 protected object Fibonacci(object num, object flag)
13 if ((bool)flag)
14 return Fibonacci2(num, flag);
15 if (((int)num % 2) == 0)
16 return Fibonacci2(num, flag);
17 return Fibonacci2(num, flag);
20 protected object Fibonacci2(object num, object flag)
22 int N;
23 if ((int)num <= 1)
24 N = (int)num;
25 else
26 N = (int)Fibonacci((int)num - 2, false) + (int)Fibonacci((int)num - 1, flag);
27 if ((bool)flag)
28 Console.Write(N.ToString() + " ");
29 return N;
32 private static int Main()
34 new Test().Fibonacci(20, true);
35 Console.WriteLine();
36 Console.WriteLine("*** PASSED ***");
37 return 100;