File: nspace_runme.2.d

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 (77 lines) | stat: -rw-r--r-- 2,674 bytes parent folder | download | duplicates (13)
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
module nspace_runme;

import std.exception;
import nspace.nspace;
static import nspace.NoNSpacePlease;
static import nspace.Outer.namespce;
static import nspace.Outer.Inner1.Channel;
static import oi1c = nspace.Outer.Inner1.Color;
static import nspace.Outer.Inner2.Channel;
static import nspace.Outer.Inner2.Color;
static import nspace.Outer.Inner3.Blue;
static import nspace.Outer.Inner4.Blue;
static import nspace.Outer.SomeClass;

void main() {
  // constructors and destructors
  auto color1 = new oi1c.Color();
  auto color = new oi1c.Color(color1);

  // class methods
  color.colorInstanceMethod(20.0);
  oi1c.Color.colorStaticMethod(20.0);
  auto created = oi1c.Color.create();

  // class enums
  auto someClass = new nspace.Outer.SomeClass.SomeClass();
  auto channel = someClass.GetInner1ColorChannel();
  enforce(channel == oi1c.Color.Channel.Transmission,
    "Transmission wrong");

  // class anonymous enums
  int val1 = oi1c.Color.ColorEnumVal1;
  int val2 = oi1c.Color.ColorEnumVal2;
  enforce(val1 == 0 && val2 == 0x22, "ColorEnumVal wrong");

  // instance member variables
  color.instanceMemberVariable = 123;
  enforce(color.instanceMemberVariable == 123,
    "instance member variable failed");

  // static member variables
  oi1c.Color.staticMemberVariable = 789;
  enforce(oi1c.Color.staticMemberVariable == 789,
    "static member variable failed");
  enforce(oi1c.Color.staticConstMemberVariable == 222,
    "static const member variable failed");
  enforce(oi1c.Color.staticConstEnumMemberVariable == oi1c.Color.Channel.Transmission,
    "static const enum member variable failed");

  // check globals in a namespace don't get mangled with the nspace option
  nspace.nspace.namespaceFunction(color);
  nspace.nspace.namespaceVar = 111;
  enforce(nspace.nspace.namespaceVar == 111, "global var failed");

  // Same class different namespaces
  auto col1 = new oi1c.Color();
  auto col2 = nspace.Outer.Inner2.Color.Color.create();
  col2.colors(col1, col1, col2, col2, col2);

  // global enums
  auto outerChannel1 = someClass.GetInner1Channel();
  enforce(outerChannel1 == nspace.Outer.Inner1.Channel.Channel.Transmission1,
      "Transmission1 wrong");
  auto outerChannel2 = someClass.GetInner2Channel();
  enforce(outerChannel2 == nspace.Outer.Inner2.Channel.Channel.Transmission2,
      "Transmission2 wrong");

  // turn feature off / ignoring
  auto ns = new nspace.Outer.namespce.namespce();
  auto nons = new nspace.NoNSpacePlease.NoNSpacePlease();

  // Derived class
  auto blue3 = new nspace.Outer.Inner3.Blue.Blue();
  blue3.blueInstanceMethod();
  auto blue4 = new nspace.Outer.Inner4.Blue.Blue();
  blue4.blueInstanceMethod();
}