summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Directed/newarr/newarr.cs
blob: b37a038f37d6a8651b3123ae89dcd8e8a6e537c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//

using System;

internal class AA
{
    private static int Main()
    {
        uint SMALL1 = 0x00000100;
        uint SMALL2 = 0x7fffffff;
        uint BIG1 = 0x80000000;
        uint BIG2 = 0xffffffff;
        int[] array = null;
        AA[,,] marray = null;
        try
        {
            array = new int[SMALL1];
            Console.WriteLine("Test 1 passed");
        }
        catch (Exception)
        {
            Console.WriteLine("Test 1 failed");
            return 101;
        }
        try
        {
            array = new int[SMALL2];
            Console.WriteLine("Test 2 failed");
            return 102;
        }
        catch (OutOfMemoryException)
        {
            Console.WriteLine("Test 2 passed");
        }
        try
        {
            array = new int[BIG1];
            Console.WriteLine("Test 3 failed");
            return 103;
        }
        catch (OverflowException)
        {
            Console.WriteLine("Test 3 passed");
        }
        try
        {
            array = new int[BIG2];
            Console.WriteLine("Test 4 failed");
            return 104;
        }
        catch (OverflowException)
        {
            Console.WriteLine("Test 4 passed");
        }
        try
        {
            marray = new AA[SMALL1, 1, SMALL1];
            Console.WriteLine("Test 5 passed");
        }
        catch (Exception)
        {
            Console.WriteLine("Test 5 failed");
            return 105;
        }
        try
        {
            marray = new AA[2, SMALL2, SMALL2];
            Console.WriteLine("Test 6 failed");
            return 106;
        }
        catch (OutOfMemoryException)
        {
            Console.WriteLine("Test 6 passed");
        }
        try
        {
            marray = new AA[BIG1, BIG1, 2];
            Console.WriteLine("Test 7 failed");
            return 107;
        }
        catch (OverflowException)
        {
            Console.WriteLine("Test 7 passed");
        }
        try
        {
            marray = new AA[BIG2, 0, 1];
            Console.WriteLine("Test 8 failed");
            return 108;
        }
        catch (OverflowException)
        {
            Console.WriteLine("Test 8 passed");
        }
        Console.WriteLine("All tests passed");
        return 100;
    }
}