File: extend_default_runme.java

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (226 lines) | stat: -rw-r--r-- 9,058 bytes parent folder | download | duplicates (17)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226

import extend_default.Override;
import extend_default.*;

public class extend_default_runme {
  static {
    try {
        System.loadLibrary("extend_default");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[]) 
  {
    // %extend before the class definition
    {
      Before ex = new Before();
      if (ex.getI() != -1.0 && ex.getD() != -1.0)
        throw new RuntimeException("Before constructor 1 failed");

      ex = new Before(10);
      if (ex.getI() != 10.0 && ex.getD() != -1.0)
        throw new RuntimeException("Before constructor 2 failed");

      ex = new Before(20, 30.0);
      if (ex.getI() != 20 && ex.getD() != 30.0)
        throw new RuntimeException("Before constructor 3 failed");
    }
    {
      Before ex = new Before();
      if (ex.AddedMethod() != -2.0)
        throw new RuntimeException("Before AddedMethod 1 failed");
      if (ex.AddedMethod(-2) != -3.0)
        throw new RuntimeException("Before AddedMethod 2 failed");
      if (ex.AddedMethod(-10, -10.0) != -20)
        throw new RuntimeException("Before AddedMethod 3 failed");
    }
    {
      if (Before.AddedStaticMethod() != -2.0)
        throw new RuntimeException("Before AddedStaticMethod 1 failed");
      if (Before.AddedStaticMethod(-2) != -3.0)
        throw new RuntimeException("Before AddedStaticMethod 2 failed");
      if (Before.AddedStaticMethod(-10, -10.0) != -20)
        throw new RuntimeException("Before AddedStaticMethod 3 failed");
    }

    // %extend after the class definition
    {
      After ex = new After();
      if (ex.getI() != -1.0 && ex.getD() != -1.0)
        throw new RuntimeException("After constructor 1 failed");

      ex = new After(10);
      if (ex.getI() != 10.0 && ex.getD() != -1.0)
        throw new RuntimeException("After constructor 2 failed");

      ex = new After(20, 30.0);
      if (ex.getI() != 20 && ex.getD() != 30.0)
        throw new RuntimeException("After constructor 3 failed");
    }
    {
      After ex = new After();
      if (ex.AddedMethod() != -2.0)
        throw new RuntimeException("After AddedMethod 1 failed");
      if (ex.AddedMethod(-2) != -3.0)
        throw new RuntimeException("After AddedMethod 2 failed");
      if (ex.AddedMethod(-10, -10.0) != -20)
        throw new RuntimeException("After AddedMethod 3 failed");
    }
    {
      if (After.AddedStaticMethod() != -2.0)
        throw new RuntimeException("After AddedStaticMethod 1 failed");
      if (After.AddedStaticMethod(-2) != -3.0)
        throw new RuntimeException("After AddedStaticMethod 2 failed");
      if (After.AddedStaticMethod(-10, -10.0) != -20)
        throw new RuntimeException("After AddedStaticMethod 3 failed");
    }

    // %extend before the class definition - with overloading and default args
    {
      OverBefore ex = new OverBefore();
      if (ex.getI() != -1.0 && ex.getD() != -1.0)
        throw new RuntimeException("OverBefore constructor 1 failed");

      ex = new OverBefore(10);
      if (ex.getI() != 10.0 && ex.getD() != -1.0)
        throw new RuntimeException("OverBefore constructor 2 failed");

      ex = new OverBefore(20, 30.0);
      if (ex.getI() != 20 && ex.getD() != 30.0)
        throw new RuntimeException("OverBefore constructor 3 failed");
    }
    {
      OverBefore ex = new OverBefore();
      if (ex.AddedMethod() != -2.0)
        throw new RuntimeException("OverBefore AddedMethod 1 failed");
      if (ex.AddedMethod(-2) != -3.0)
        throw new RuntimeException("OverBefore AddedMethod 2 failed");
      if (ex.AddedMethod(-10, -10.0) != -20)
        throw new RuntimeException("OverBefore AddedMethod 3 failed");
    }
    {
      if (OverBefore.AddedStaticMethod() != -2.0)
        throw new RuntimeException("OverBefore AddedStaticMethod 1 failed");
      if (OverBefore.AddedStaticMethod(-2) != -3.0)
        throw new RuntimeException("OverBefore AddedStaticMethod 2 failed");
      if (OverBefore.AddedStaticMethod(-10, -10.0) != -20)
        throw new RuntimeException("OverBefore AddedStaticMethod 3 failed");
    }
    {
      OverBefore ex = new OverBefore("hello");
      if (ex.getI() != -2.0 && ex.getD() != -2.0)
        throw new RuntimeException("OverBefore overload constructor 1 failed");

      ex = new OverBefore("hello", 10);
      if (ex.getI() != 10.0 && ex.getD() != -1.0)
        throw new RuntimeException("OverBefore overload constructor 2 failed");

      ex = new OverBefore("hello", 20, 30.0);
      if (ex.getI() != 20 && ex.getD() != 30.0)
        throw new RuntimeException("OverBefore overload constructor 3 failed");
    }
    {
      OverBefore ex = new OverBefore("hello");
      if (ex.AddedMethod("hello") != -2.0)
        throw new RuntimeException("OverBefore overload AddedMethod 1 failed");
      if (ex.AddedMethod("hello", -2) != -3.0)
        throw new RuntimeException("OverBefore overload AddedMethod 2 failed");
      if (ex.AddedMethod("hello", -10, -10.0) != -20)
        throw new RuntimeException("OverBefore overload AddedMethod 3 failed");
    }
    {
      if (OverBefore.AddedStaticMethod("hello") != -2.0)
        throw new RuntimeException("OverBefore overload AddedStaticMethod 1 failed");
      if (OverBefore.AddedStaticMethod("hello", -2) != -3.0)
        throw new RuntimeException("OverBefore overload AddedStaticMethod 2 failed");
      if (OverBefore.AddedStaticMethod("hello", -10, -10.0) != -20)
        throw new RuntimeException("OverBefore overload AddedStaticMethod 3 failed");
    }

    // %extend after the class definition - with overloading and default args
    {
      OverAfter ex = new OverAfter();
      if (ex.getI() != -1.0 && ex.getD() != -1.0)
        throw new RuntimeException("OverAfter constructor 1 failed");

      ex = new OverAfter(10);
      if (ex.getI() != 10.0 && ex.getD() != -1.0)
        throw new RuntimeException("OverAfter constructor 2 failed");

      ex = new OverAfter(20, 30.0);
      if (ex.getI() != 20 && ex.getD() != 30.0)
        throw new RuntimeException("OverAfter constructor 3 failed");
    }
    {
      OverAfter ex = new OverAfter();
      if (ex.AddedMethod() != -2.0)
        throw new RuntimeException("OverAfter AddedMethod 1 failed");
      if (ex.AddedMethod(-2) != -3.0)
        throw new RuntimeException("OverAfter AddedMethod 2 failed");
      if (ex.AddedMethod(-10, -10.0) != -20)
        throw new RuntimeException("OverAfter AddedMethod 3 failed");
    }
    {
      if (OverAfter.AddedStaticMethod() != -2.0)
        throw new RuntimeException("OverAfter AddedStaticMethod 1 failed");
      if (OverAfter.AddedStaticMethod(-2) != -3.0)
        throw new RuntimeException("OverAfter AddedStaticMethod 2 failed");
      if (OverAfter.AddedStaticMethod(-10, -10.0) != -20)
        throw new RuntimeException("OverAfter AddedStaticMethod 3 failed");
    }
    {
      OverAfter ex = new OverAfter("hello");
      if (ex.getI() != -2.0 && ex.getD() != -2.0)
        throw new RuntimeException("OverAfter overload constructor 1 failed");

      ex = new OverAfter("hello", 10);
      if (ex.getI() != 10.0 && ex.getD() != -1.0)
        throw new RuntimeException("OverAfter overload constructor 2 failed");

      ex = new OverAfter("hello", 20, 30.0);
      if (ex.getI() != 20 && ex.getD() != 30.0)
        throw new RuntimeException("OverAfter overload constructor 3 failed");
    }
    {
      OverAfter ex = new OverAfter("hello");
      if (ex.AddedMethod("hello") != -2.0)
        throw new RuntimeException("OverAfter overload AddedMethod 1 failed");
      if (ex.AddedMethod("hello", -2) != -3.0)
        throw new RuntimeException("OverAfter overload AddedMethod 2 failed");
      if (ex.AddedMethod("hello", -10, -10.0) != -20)
        throw new RuntimeException("OverAfter overload AddedMethod 3 failed");
    }
    {
      if (OverAfter.AddedStaticMethod("hello") != -2.0)
        throw new RuntimeException("OverAfter overload AddedStaticMethod 1 failed");
      if (OverAfter.AddedStaticMethod("hello", -2) != -3.0)
        throw new RuntimeException("OverAfter overload AddedStaticMethod 2 failed");
      if (OverAfter.AddedStaticMethod("hello", -10, -10.0) != -20)
        throw new RuntimeException("OverAfter overload AddedStaticMethod 3 failed");
    }

    // Override
    {
      Override o = new Override();

      if (o.over() != -1)
        throw new RuntimeException("override test 1 failed");
      if (o.over(10) != 10*10)
        throw new RuntimeException("override test 2 failed");

      if (o.ride() != -1)
        throw new RuntimeException("override test 3 failed");
      if (o.ride(10) != 10)
        throw new RuntimeException("override test 4 failed");

      if (o.overload() != -10)
        throw new RuntimeException("override test 5 failed");
      if (o.overload(10) != 10*10)
        throw new RuntimeException("override test 6 failed");
    }
  }
}