murano/murano/tests/unit/dsl/meta/TestGC.yaml

80 lines
1.5 KiB
YAML

Name: TestGCNode
Extends: Node
Methods:
.init:
Body:
- $.find(Node)
foo:
Body:
- trace(foo)
destructionHandler:
Arguments:
- obj:
Contract: $.class(TestGCNode).notNull()
Body:
- trace('Destruction of {0}'.format($obj.value))
.destroy:
Body:
- trace($.value)
---
Namespaces:
sys: io.murano.system
Name: TestGC
Methods:
testObjectsCollect:
Body:
- $model:
:TestGCNode:
value: A
nodes:
- :TestGCNode:
value: B
- new($model)
- sys:GC.collect()
testObjectsCollectWithSubscription:
Body:
- $model:
:TestGCNode:
value: A
nodes:
:TestGCNode:
value: B
- $x: new($model)
- sys:GC.subscribeDestruction($x, $this, _handler)
- sys:GC.subscribeDestruction($x.nodes[0], $this, _handler)
- sys:GC.subscribeDestruction($x.nodes[0], $x, destructionHandler)
- $x: null
- sys:GC.collect()
_handler:
Arguments:
- obj:
Contract: $.class(TestGCNode).notNull()
Body:
- trace('Destroy ' + $obj.value)
testCallOnDestroyedObject:
Body:
- $val: new(TestGCNode, value => X)
- sys:GC.subscribeDestruction($val, $this, _handler2)
- $val: null
- sys:GC.collect()
- $this.destroyed.foo()
_handler2:
Arguments:
- obj:
Contract: $.class(TestGCNode).notNull()
Body:
- $obj.foo()
- $this.destroyed: $obj