Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Feb 2, 2025
1 parent a504eba commit 39f2435
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions vlib/v/tests/options/option_ptr_unwrap_selector_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module main

@[heap]
interface IGameObject {
mut:
name string
parent ?&IGameObject
children []&IGameObject
add_child(mut o IGameObject)
}

@[heap]
struct GameObject implements IGameObject {
mut:
name string
parent ?&IGameObject
children []&IGameObject
}

fn (mut gameobject GameObject) add_child(mut o IGameObject) {
o.parent = gameobject
gameobject.children << o
}

fn test_main() {
mut v1 := &GameObject{
name: 'v1'
}
mut v2 := &GameObject{
name: 'v2'
}
v1.add_child(mut v2)
for child in v1.children {
if child.parent != none {
eprintln('parent: ${child.parent.name}')
}
}
assert true
}

0 comments on commit 39f2435

Please sign in to comment.