Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / ckfiniteTest.il
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
7
8 .assembly extern mscorlib{}
9 .assembly someTest{}
10 .module someTest
11
12 .class private auto ansi someTest
13        extends [mscorlib]System.Object {
14
15   .method public static int32 Main() cil managed {
16     .entrypoint
17     .locals (int32 res)
18
19         ldc.i4 3
20         stloc res
21 //TEST 1 - infinite
22
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
31 }
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
41 }
42 catch [mscorlib]System.Exception {
43         pop
44         ldstr "EFAIL"
45         call void [mscorlib]System.Console::WriteLine(string)
46         leave test2
47 }
48
49 //TEST 2 - NaN
50 test2: nop
51
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
60 }
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
69 }
70 catch [mscorlib]System.Exception {
71         ldstr "FAIL"
72         call void [mscorlib]System.Console::WriteLine(string)
73         leave test3
74 }
75
76 //TEST 3
77 test3: nop
78
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
95 }
96 catch [mscorlib]System.Exception {
97         ldstr "FAIL"
98         call void [mscorlib]System.Console::WriteLine(string)
99         leave end
100 }
101
102 end:    
103         ldloc res
104         ret
105   }
106
107
108