Skip to content

Commit de75867

Browse files
committed
Add processors tests
1 parent 3c3a254 commit de75867

11 files changed

+177
-1
lines changed

main.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ func _ready():
1919
preload("res://test/test_suites/file_tests.gd").execute(tests_results)
2020
preload("res://test/test_suites/json_config_file_tests.gd").execute(tests_results)
2121
preload("res://test/test_suites/image_tests.gd").execute(tests_results)
22+
preload("res://test/test_suites/processor_tests.gd").execute(tests_results)

project.godot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ _global_script_classes=[ {
2525
"path": "res://src/json_config_file/json_config_file.gd"
2626
}, {
2727
"base": "Reference",
28+
"class": "JSONConfigProcessor",
29+
"language": "GDScript",
30+
"path": "res://src/json_config_file/json_config_processor.gd"
31+
}, {
32+
"base": "Reference",
2833
"class": "JSONProperty",
2934
"language": "GDScript",
3035
"path": "res://src/json_config_file/json_properties/json_property.gd"
@@ -98,6 +103,7 @@ _global_script_class_icons={
98103
"Case": "",
99104
"Comparator": "",
100105
"JSONConfigFile": "",
106+
"JSONConfigProcessor": "",
101107
"JSONProperty": "",
102108
"JSONPropertyArray": "",
103109
"JSONPropertyBool": "",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
extends JSONConfigProcessor
2+
3+
4+
func _process(dic : Dictionary):
5+
if not has_variable("id"):
6+
dic.id = 0
7+
set_variable("id", 0)
8+
else:
9+
var id = get_variable("id") + 1
10+
dic.id = id
11+
set_variable("id", id)
12+
13+
return dic
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"objects": [
3+
{
4+
"name": "table"
5+
},
6+
{
7+
"name": "lamp"
8+
},
9+
{
10+
"name": "chair"
11+
}
12+
]
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"min": 0,
3+
"max": 3,
4+
"a_value": 2
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"min": 0,
3+
"max": 3,
4+
"a_value": 4
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends JSONConfigProcessor
2+
3+
4+
func _process(maximum : int):
5+
set_variable("max", maximum)
6+
7+
return maximum
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends JSONConfigProcessor
2+
3+
4+
func _process(minimum : int):
5+
set_variable("min", minimum)
6+
7+
return minimum
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extends JSONConfigProcessor
2+
3+
4+
func _process(_value):
5+
if has_variable("min"):
6+
get_property().set_min_value(get_variable("min"))
7+
if has_variable("max"):
8+
get_property().set_max_value(get_variable("max"))

0 commit comments

Comments
 (0)