PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
D | 50 lines | 40 code | 10 blank | 0 comment | 10 complexity | 4ac1d231d46e3600838dedc987778e00 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. module director_protected_runme;
  2. import director_protected.Foo;
  3. import director_protected.Bar;
  4. void main() {
  5. Bar b = new Bar();
  6. Foo f = b.create();
  7. auto fb = new FooBar();
  8. auto fb2 = new FooBar2();
  9. char[] s;
  10. s = fb.used();
  11. if ( s != ("Foo::pang();Bar::pong();Foo::pong();FooBar::ping();"))
  12. throw new Exception("bad FooBar::used" ~ " - " ~ s);
  13. s = fb2.used();
  14. if ( s != ("FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();"))
  15. throw new Exception("bad FooBar2::used");
  16. s = b.pong();
  17. if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
  18. throw new Exception("bad Bar::pong");
  19. s = f.pong();
  20. if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
  21. throw new Exception("bad Foo::pong");
  22. s = fb.pong();
  23. if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
  24. throw new Exception("bad FooBar::pong");
  25. }
  26. class FooBar : Bar {
  27. protected:
  28. override char[] ping() {
  29. return "FooBar::ping();";
  30. }
  31. }
  32. class FooBar2 : Bar{
  33. protected:
  34. override char[] ping() {
  35. return "FooBar2::ping();";
  36. }
  37. override char[] pang() {
  38. return "FooBar2::pang();";
  39. }
  40. }