Namespaces:
  std: io.murano

Name: CreatingClass

Properties:
  yyy:
    Contract: $
    Usage: Out


Methods:
  .init:
    Body:
      trace('CreatingClass::.init')

  testNew:
    Body:
      - new(CreatedClass1, property1 => string, property2 => 123)

  testNewWithOwnership:
    Body:
      - $.yyy: new(CreatedClass1, property1 => string, property2 => 123)
      - Return: $.yyy.createClass2($this)

  testNewWithDict:
    Body:
      - $dict:
          property1: string
          property2: 123
      - Return: new(CreatedClass1, $dict, owner=>$this)

  testLoadCompexModel:
    Body:
      - $model:
          :Node:
            value: rootNode
            nodes:
              - :Node:
                  value: childNode1
                  nodes: [node0, node2]
                id: node1
              - '?':
                  id: node2
                  type: Node
                value: childNode2
                nodes: [node1, node2]
              - node2
          id: node0
      - $obj: new($model, $this)
      - Return:
        - id($obj)
        - id($obj.nodes[0])
        - id($obj.nodes[1])
        - id($obj.find(std:Object))
        - $obj.value
        - $obj.nodes.select($.value)
        - $obj.nodes[0].nodes[0] = $obj
        - $obj.nodes[0].nodes[1] = $obj.nodes[1]
        - $obj.nodes[2] = $obj.nodes[1]
        - $obj.nodes[1].nodes[0] = $obj.nodes[0]
        - $obj.nodes[1].nodes[1] = $obj.nodes[1]
        - $obj.nodes[0].nodes[0].value
        - $obj.nodes[0].nodes[1].value
        - $obj.nodes[1].nodes[0].value

  testSingleContractInstantiation:
    Body:
      - $model:
          :ConstructionSample:
      - new(:ConstructionChild, prop => $model)

  testNestedNewLoadsInSeparateStore:
    Body:
      Return: new(:ConstructionFromInit).out.nodes[1]

  testReferenceAccessFromInit:
    Body:
      - $model:
          :Node:
            value: rootNode
            nodes:
              - childNode
              - :NodeWithReferenceAccess:
                  value: childNode
                id: childNode
      - $.out: new($model, $this)

---

Name: ConstructionSample
Methods:
  .init:
    Body: trace('ConstructionSample::init')

---

Name: ConstructionParent
Properties:
  prop:
    Contract: $.class(ConstructionSample)

---

Name: ConstructionChild
Extends: ConstructionParent
Properties:
  prop:
    Contract: $.class(ConstructionSample)

---

Name: ConstructionFromInit
Properties:
  out:
    Contract: $.class(Node)
    Usage: Out
Methods:
  .init:
    Body:
      - $model:
          :Node:
            value: rootNode
            nodes:
              - :Node:
                  value: childNode1
                  nodes: [childNode2]
                id: childNode1
              - :Node:
                  value: childNode2
                  nodes: [childNode1]
                id: childNode2
      - $.out: new($model, $this)

---

Name: NodeWithReferenceAccess
Extends: Node

Methods:
  .init:
    Body: $.find(Node).nodes.select(trace($.value))