nested_class2.gravity 579 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #unittest {
  2. name: "Complex nested classes example.";
  3. error: NONE;
  4. result: 667;
  5. };
  6. class c1 {
  7. public var p1;
  8. class c2 {
  9. public var p2;
  10. class c3 {
  11. public var p3;
  12. class c4 {
  13. class c5 {
  14. public var p6;
  15. // c5 init
  16. func init() {
  17. p6 = 667;
  18. }
  19. }
  20. func p5() {
  21. return c5();
  22. }
  23. }
  24. // c3 init
  25. func init() {
  26. p3 = [c4, c4, c4, c4];
  27. }
  28. }
  29. // c2 init
  30. func init() {
  31. p2 = c3();
  32. }
  33. }
  34. // c1 init
  35. func init() {
  36. p1 = c2();
  37. }
  38. }
  39. func main() {
  40. return c1().p1.p2.p3[2]().p5().p6;
  41. }