forked from jamie-pate/godot-code-coverage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spatial.gd
73 lines (63 loc) · 1.77 KB
/
Spatial.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
tool
class_name Spatial1 extends Spatial
const Other = preload("./Other.gd")
const CustomLabel = preload("./CustomLabel.gd")
var auto_quit := true
signal done()
class Inner:
tool
extends Reference
class InnerEmpty:
extends Reference
static func fmt(value: String):
return 'Inner(%s)' % [value]
class InnerExtends extends Reference:
func fmt(value: String):
return 'InterExtends(%s)' % [value]
# Called when the node enters the scene tree for the first time.
func _ready():
var other = Other.new()
$Label.text = InnerExtends.new().fmt(Inner.fmt(other.fmt("hello world")))
func _on_Timer_timeout():
print('add child')
var custom_label := CustomLabel.new()
add_child(custom_label)
custom_label.margin_top = 20
var other = Other.new()
var text := Autoload1.fmt("timeout")
$Label.text = text
custom_label.custom_text = \
$Label.text
for i in range(2):
yield(get_tree(), "idle_frame")
if i == 0:
$Label.text = other.fmt(str(i))
elif i == 1:
$Label.text = (
other.fmt(str(i * 1))
)
else:
var x = {
a=1
}
$Label.text = other.fmt(str(i * 2) + str(x))
match i:
0:
$Label.text = other.fmt(str(i))
# 1
1:
$Label.text = other.fmt(str(i * 1))
3: $Label.text = other.fmt(str(i * 1))
custom_label.custom_text = $Label.text
yield(get_tree(), "idle_frame")
assert(Autoload2._counter == '3', "Autoload2 counter should be 3 because Autoload1 'formatting' signal fired")
$Label.text = Autoload2.fmt("done")
custom_label.custom_text = $Label.text
yield(get_tree().create_timer(.5), "timeout")
print("Performance takes %sus" % [Other.new().performance_test()])
emit_signal("done")
if auto_quit:
print('This line is not covered in the unit tests')
get_tree().quit()
else:
print('This line is not covered in the CoverageTree tests')