mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
44 lines
855 B
Plaintext
44 lines
855 B
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
// CHECK:STDOUT: Allocate B
|
|
// CHECK:STDOUT: DESTRUCTOR B
|
|
// CHECK:STDOUT: DESTRUCTOR A
|
|
// CHECK:STDOUT: Delete B
|
|
// CHECK:STDOUT: DESTRUCTOR B
|
|
// CHECK:STDOUT: DESTRUCTOR A
|
|
// CHECK:STDOUT: Return
|
|
// CHECK:STDOUT: result: 0
|
|
|
|
package ExplorerTest api;
|
|
|
|
|
|
base class A{
|
|
destructor[self: Self] {
|
|
Print("DESTRUCTOR A");
|
|
}
|
|
}
|
|
|
|
class B {
|
|
extend base: A;
|
|
fn Create() -> Self{
|
|
return {.base={}};
|
|
}
|
|
destructor[self: Self] {
|
|
Print("DESTRUCTOR B");
|
|
}
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
Print("Allocate B");
|
|
var pb: B* = heap.New(B.Create());
|
|
|
|
Print("Delete B");
|
|
heap.Delete(pb);
|
|
|
|
Print("Return");
|
|
return 0;
|
|
}
|