Debian Codegraph @

modules/gdscript/tests/scripts/runtime/features/duplicate_resource.gd

raw
1 # We could use @export_custom to really test every property usage, but we know for good
2 # that duplicating scripted properties flows through the same code already thoroughly tested
3 # in the [Resource] test cases. The same goes for all the potential deep duplicate modes.
4 # Therefore, it's enough to ensure the exported scriped properties are copied when invoking
5 # duplication by each entry point.
6 class TestResource:
7 extends Resource
8 @export var text: String = "holaaa"
9 @export var arr: Array = [1, 2, 3]
10 @export var dict: Dictionary = { "a": 1, "b": 2 }
11
12 func test():
13 # Via Resource type.
14 var res := TestResource.new()
15 var dupe: TestResource
16
17 dupe = res.duplicate()
18 print(dupe.text)
19 print(dupe.arr)
20 print(dupe.dict)
21
22 dupe = res.duplicate_deep()
23 print(dupe.text)
24 print(dupe.arr)
25 print(dupe.dict)
26
27 # Via Variant type.
28
29 var res_var = TestResource.new()
30 var dupe_var
31
32 dupe_var = res_var.duplicate()
33 print(dupe_var.text)
34 print(dupe_var.arr)
35 print(dupe_var.dict)
36
37 dupe_var = res_var.duplicate_deep()
38 print(dupe_var.text)
39 print(dupe_var.arr)
40 print(dupe_var.dict)