Bump corefx
[mono-project.git] / mono / tests / ckfiniteTest.il
blob05d0540ea2bf8b45b795794d215d989afb8c8712
1 //Tests the ckfinite instruction
2 //First test on an infinite (finite / 0)
3 //Second test on NaN (0 / 0)
4 //Third test sees if value is left on stack if finite
5 //Both print either PASS or FAIL
6 //Assumes div works as per specifications
8 .assembly extern mscorlib{}
9 .assembly someTest{}
10 .module someTest
12 .class private auto ansi someTest
13        extends [mscorlib]System.Object {
15   .method public static int32 Main() cil managed {
16     .entrypoint
17     .locals (int32 res)
19         ldc.i4 3
20         stloc res
21 //TEST 1 - infinite
23 .try {
24         ldc.r8 1
25         ldc.r8 0
26         div
27         ckfinite
28         ldstr "FAIL"
29         call void [mscorlib]System.Console::WriteLine(string)
30         leave test2
32 catch [mscorlib]System.ArithmeticException {
33         pop
34         ldstr "PASS"
35         call void [mscorlib]System.Console::WriteLine(string)
36         ldloc res
37         ldc.i4 1
38         sub
39         stloc res
40         leave test2
42 catch [mscorlib]System.Exception {
43         pop
44         ldstr "EFAIL"
45         call void [mscorlib]System.Console::WriteLine(string)
46         leave test2
49 //TEST 2 - NaN
50 test2: nop
52 .try {
53         ldc.r8 0
54         ldc.r8 0
55         div
56         ckfinite
57         ldstr "FAIL"
58         call void [mscorlib]System.Console::WriteLine(string)
59         leave test3
61 catch [mscorlib]System.ArithmeticException {
62         ldstr "PASS"
63         call void [mscorlib]System.Console::WriteLine(string)
64         ldloc res
65         ldc.i4 1
66         sub
67         stloc res
68         leave test3
70 catch [mscorlib]System.Exception {
71         ldstr "FAIL"
72         call void [mscorlib]System.Console::WriteLine(string)
73         leave test3
76 //TEST 3
77 test3: nop
79 .try {
80         ldc.r8 3.777
81         ckfinite
82         ldc.r8 3.777
83         bne.un FAIL
84         ldstr "PASS"
85         call void [mscorlib]System.Console::WriteLine(string)
86         ldloc res
87         ldc.i4 1
88         sub
89         stloc res
90         leave end
91                                 
92 FAIL:   ldstr "FAIL"
93         call void [mscorlib]System.Console::WriteLine(string)
94         leave end
96 catch [mscorlib]System.Exception {
97         ldstr "FAIL"
98         call void [mscorlib]System.Console::WriteLine(string)
99         leave end
102 end:    
103         ldloc res
104         ret
105   }