2010-04-07 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-141.cs
blobf45e00ad51f77949d204f6f4a1b2ef8cf1f3f5d5
1 using System;
3 class X {
4 public static int Main()
6 if (! Test1 ()) return 1;
7 if (! Test2 ()) return 2;
8 if (! Test3 ()) return 3;
10 return 0;
13 static bool Test1 ()
15 byte num1 = 105;
16 byte num2 = 150;
18 // should generate OverflowException
19 try {
20 checked {
21 byte sum = (byte) (num1 - num2);
24 return false;
25 } catch (OverflowException) {
26 return true;
30 static bool Test2 ()
32 long l = long.MinValue;
34 // should generate OverflowException
35 try {
36 checked {
37 l = - l;
40 return false;
41 } catch (OverflowException) {
42 return true;
46 static bool Test3 ()
48 int i = int.MinValue;
50 // should generate OverflowException
51 try {
52 checked {
53 i = - i;
56 return false;
57 } catch (OverflowException) {
58 return true;