New test.
[mono.git] / mono / tests / cas / linkdemand / icall5.cs
1 using System;
2 using System.Runtime.CompilerServices;
3 using System.Security;
4 using System.Security.Permissions;
5
6 [assembly: SecurityPermission (SecurityAction.RequestRefuse, UnmanagedCode=true)]
7
8 namespace System {
9
10         // this is a "public" internal call for both Mono and Microsoft
11         // http://groups.google.ca/groups?q=MethodImplAttribute+InternalCall&hl=en&lr=&selm=udngxsETCHA.1468%40tkmsftngp11&rnum=10
12         public class Math {
13
14                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
15                 public static extern double Sin (double a);
16         }
17 }
18
19 public class Program {
20
21         static int TestICall ()
22         {
23                 return (int) System.Math.Sin (0);
24         }
25
26         static int Main ()
27         {
28                 try {
29                         Console.WriteLine ("*0* System.Math.Sin(0) == {0}", TestICall ());
30                         return 0;
31                 }
32                 catch (SecurityException se) {
33                         Console.WriteLine ("*1* SecurityException\n{0}", se);
34                         return 1;
35                 }
36                 catch (Exception e) {
37                         Console.WriteLine ("*2* Unexpected exception\n{0}", e);
38                         return 2;
39                 }
40         }
41 }