1 // EXTRA_SOURCES: imports/testcontracts.d
2 
3 import imports.testcontracts;
4 
5 /***************************************************/
6 // https://issues.dlang.org/show_bug.cgi?id=3602
7 
8 class Derived3602 : Base3602
9 {
method(int x,int y)10    override void method(int x, int y)
11    in
12    {
13        assert(x > 0);
14        assert(y > 0);
15    }
16    body
17    {
18    }
19 }
20 
21 /***************************************************/
22 // https://issues.dlang.org/show_bug.cgi?id=5230
23 
24 class Derived5230 : Base5230
25 {
method()26     override int method()
27     {
28         return 69;
29     }
30 }
31 
32 /***************************************************/
33 // https://issues.dlang.org/show_bug.cgi?id=17502
34 class Foo17502
35 {
foo()36     auto foo()
37     out {}
38     body {}
39 
bar()40     auto bar()
41     out { assert (__result > 5); }
42     body { return 6; }
43 
bar_2()44     auto bar_2()
45     out (res) { assert (res > 5); }
46     body { return 6; }
47 
concrete()48     int concrete()
49     out { assert(__result > 5); }
50     body { return 6; }
51 
concrete_2()52     int concrete_2()
53     out(res) { assert (res > 5); }
54     body { return 6; }
55 
void_foo()56     void void_foo()
57     out {}
58     body {}
59 
void_auto()60     auto void_auto()
61     out {}
62     body {}
63 }
64 
65 /***************************************************/
66 // Order of declaration: (A), (C : B), (B : A)
67 
68 class A17502
69 {
method(int p)70     int method(int p)
71     in
72     {
73         assert(p > 5);
74     }
out(res)75     out(res)
76     {
77         assert(res > 5);
78     }
79     body
80     {
81         return p;
82     }
83 }
84 
85 class C17502 : B17502
86 {
method(int p)87     override int method(int p)
88     in
89     {
90         assert(p > 3);
91     }
92     body
93     {
94         return p * 2;
95     }
96 }
97 
98 class B17502 : A17502
99 {
method(int p)100     override int method(int p)
101     in
102     {
103         assert(p > 2);
104     }
105     body
106     {
107         return p * 3;
108     }
109 }
110 
111 /***************************************************/
112 // Order of declaration: (X : Y), (Y : Z), (Z)
113 
114 class X17502 : Y17502
115 {
method(int p)116     override int method(int p)
117     in
118     {
119         assert(p > 3);
120     }
121     body
122     {
123         return p * 2;
124     }
125 }
126 
127 class Y17502 : Z17502
128 {
method(int p)129     override int method(int p)
130     in
131     {
132         assert(p > 2);
133     }
134     body
135     {
136         return p * 3;
137     }
138 }
139 
140 class Z17502
141 {
method(int p)142     int method(int p)
143     in
144     {
145         assert(p > 5);
146     }
out(res)147     out(res)
148     {
149         assert(res > 5);
150     }
151     body
152     {
153         return p;
154     }
155 }
156 
157 /***************************************************/
158 // https://issues.dlang.org/show_bug.cgi?id=17893
159 
Foo17893(T)160 final class Foo17893(T)
161 {
162     extern(C) void maythrow();
163 
164     void bar()
165     in
166     {
167         maythrow();
168     }
169     body
170     {
171     }
172 }
173 
174 Foo17893!int foo17893;
175