PageRenderTime 23ms CodeModel.GetById 10ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/d/allprotected_runme.1.d

#
D | 65 lines | 51 code | 14 blank | 0 comment | 22 complexity | 10023ad077280fb07b0130aebbf53740 MD5 | raw file
 1module allprotected_runme;
 2
 3import allprotected.Klass;
 4import allprotected.ProtectedBase;
 5
 6void main() {
 7  auto mpb = new MyProtectedBase("MyProtectedBase");
 8  mpb.accessProtected();
 9}
10
11class MyProtectedBase : ProtectedBase {
12public:
13  this(char[] name) {
14    super(name);
15  }
16
17  void accessProtected() {
18    char[] s = virtualMethod();
19    if (s != "ProtectedBase")
20      throw new Exception("Failed");
21
22    Klass k = instanceMethod(new Klass("xyz"));
23    if (k.getName() != "xyz") 
24      throw new Exception("Failed");
25
26    k = instanceOverloaded(new Klass("xyz"));
27    if (k.getName() != "xyz") 
28      throw new Exception("Failed");
29
30    k = instanceOverloaded(new Klass("xyz"), "abc");
31    if (k.getName() != "abc") 
32      throw new Exception("Failed");
33
34    k = staticMethod(new Klass("abc"));
35    if (k.getName() != "abc") 
36      throw new Exception("Failed");
37
38    k = staticOverloaded(new Klass("xyz"));
39    if (k.getName() != "xyz") 
40      throw new Exception("Failed");
41
42    k = staticOverloaded(new Klass("xyz"), "abc");
43    if (k.getName() != "abc") 
44      throw new Exception("Failed");
45
46    instanceMemberVariable = 30;
47    int i = instanceMemberVariable;
48    if (i != 30)
49      throw new Exception("Failed");
50
51    staticMemberVariable = 40;
52    i = staticMemberVariable;
53    if (i != 40)
54      throw new Exception("Failed");
55
56    i = staticConstMemberVariable;
57    if (i != 20)
58      throw new Exception("Failed");
59
60    anEnum = ProtectedBase.AnEnum.EnumVal1;
61    ProtectedBase.AnEnum ae = anEnum;
62    if (ae != ProtectedBase.AnEnum.EnumVal1)
63      throw new Exception("Failed");
64  }
65}