f0122e82b0498ec11a6a9d68e6de8440d891b272 770 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // CHECK:STDOUT: DESTRUCTOR C 1
  7. // CHECK:STDOUT: DESTRUCTOR B 2
  8. // CHECK:STDOUT: DESTRUCTOR A 3
  9. // CHECK:STDOUT: result: 1
  10. package ExplorerTest;
  11. class A{
  12. destructor[self: Self]{
  13. Print("DESTRUCTOR A {0}",self.n);
  14. }
  15. var n: i32;
  16. }
  17. class B{
  18. destructor[self: Self]{
  19. Print("DESTRUCTOR B {0}",self.n);
  20. }
  21. var n: i32;
  22. }
  23. class C{
  24. destructor[self: Self]{
  25. Print("DESTRUCTOR C {0}",self.n);
  26. }
  27. var n: i32;
  28. }
  29. fn Main() -> i32 {
  30. var a: A = {.n = 3};
  31. var b: B = {.n = 2};
  32. var c: C = {.n = 1};
  33. return 1;
  34. }