Skip to content

Commit

Permalink
Godot 4 stub accessors (#476)
Browse files Browse the repository at this point in the history
* some wiki updates
* can double scripts with new accessors
* version bump
* code review
  • Loading branch information
bitwes authored Mar 12, 2023
1 parent 878d097 commit 6e8dca6
Show file tree
Hide file tree
Showing 43 changed files with 624 additions and 421 deletions.
2 changes: 1 addition & 1 deletion .gutconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"should_maximize": false,
"should_exit": true,
"ignore_pause": true,
"log_level": 0,
"log_level": 3,
"double_strategy": "partial",
"include_subdirs": true,
"inner_class": "",
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

# 9.0.1
* Fix #475, you can now double scripts that use the new accessors.

# 9.0.0
9.0.0 is the first version of GUT released for Godot 4. Any version below 9.0.0 is for 3.x. See the [GODOT_4_README.md](https://github.com/bitwes/Gut/blob/godot_4/GODOT_4_README.md) in the `godot_4` branch for changes to GUT from 3.x.

Expand Down
8 changes: 6 additions & 2 deletions addons/gut/doubler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ func _get_base_script_text(parsed, override_path, partial):
return _base_script_text.format(values)


func _is_valid_double_method(parsed_script, parsed_method):
return !parsed_method.is_accessor() and \
!parsed_method.is_black_listed() and \
!_ignored_methods.has(parsed_script.resource, parsed_method.meta.name)

func _create_double(parsed, strategy, override_path, partial):
var base_script = _get_base_script_text(parsed, override_path, partial)
Expand All @@ -183,7 +187,7 @@ func _create_double(parsed, strategy, override_path, partial):
dbl_src += base_script

for method in parsed.get_local_methods():
if(!method.is_black_listed() && !_ignored_methods.has(parsed.resource, method.meta.name)):
if(_is_valid_double_method(parsed, method)):
var mthd = parsed.get_local_method(method.meta.name)
if(parsed.is_native):
dbl_src += _get_func_text(method.meta, parsed.resource, super_name)
Expand All @@ -192,7 +196,7 @@ func _create_double(parsed, strategy, override_path, partial):

if(strategy == _utils.DOUBLE_STRATEGY.INCLUDE_SUPER):
for method in parsed.get_super_methods():
if(!method.is_black_listed() && !_ignored_methods.has(parsed.resource, method.meta.name)):
if(_is_valid_double_method(parsed, method)):
_stub_to_call_super(parsed, method.meta.name)
if(parsed.is_native):
dbl_src += _get_func_text(method.meta, parsed.resource, super_name)
Expand Down
16 changes: 8 additions & 8 deletions addons/gut/gui/GutBottomPanel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

[sub_resource type="Shortcut" id="9"]

[sub_resource type="Image" id="Image_w3gk7"]
[sub_resource type="Image" id="Image_18d1g"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
Expand All @@ -18,8 +18,8 @@ data = {
"width": 16
}

[sub_resource type="ImageTexture" id="ImageTexture_ecrrc"]
image = SubResource("Image_w3gk7")
[sub_resource type="ImageTexture" id="ImageTexture_8u17l"]
image = SubResource("Image_18d1g")

[node name="GutBottomPanel" type="Control"]
custom_minimum_size = Vector2(250, 250)
Expand Down Expand Up @@ -68,18 +68,19 @@ layout_mode = 2
[node name="RunResultsBtn" type="Button" parent="layout/ControlBar"]
layout_mode = 2
toggle_mode = true
icon = SubResource("ImageTexture_ecrrc")
button_pressed = true
icon = SubResource("ImageTexture_8u17l")

[node name="OutputBtn" type="Button" parent="layout/ControlBar"]
layout_mode = 2
toggle_mode = true
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="Settings" type="Button" parent="layout/ControlBar"]
layout_mode = 2
toggle_mode = true
button_pressed = true
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="Sep2" type="ColorRect" parent="layout/ControlBar"]
custom_minimum_size = Vector2(1, 2.08165e-12)
Expand All @@ -88,7 +89,7 @@ layout_mode = 2
[node name="Shortcuts" type="Button" parent="layout/ControlBar"]
layout_mode = 2
size_flags_vertical = 11
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="RSplit" type="HSplitContainer" parent="layout"]
layout_mode = 2
Expand Down Expand Up @@ -217,7 +218,6 @@ size_flags_horizontal = 3
size_flags_vertical = 3

[node name="RunResults" parent="layout/RSplit/CResults/TabBar" instance=ExtResource("5")]
visible = false
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
Expand Down
8 changes: 4 additions & 4 deletions addons/gut/gui/GutSceneTheme.tres

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions addons/gut/gui/RunResults.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ext_resource type="Script" path="res://addons/gut/gui/RunResults.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://dls5r5f6157nq" path="res://addons/gut/gui/ResultsTree.tscn" id="2_o808v"]

[sub_resource type="Image" id="Image_w3gk7"]
[sub_resource type="Image" id="Image_18d1g"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
Expand All @@ -12,8 +12,8 @@ data = {
"width": 16
}

[sub_resource type="ImageTexture" id="ImageTexture_ecrrc"]
image = SubResource("Image_w3gk7")
[sub_resource type="ImageTexture" id="ImageTexture_8u17l"]
image = SubResource("Image_18d1g")

[node name="RunResults" type="Control"]
custom_minimum_size = Vector2(345, 0)
Expand All @@ -34,11 +34,11 @@ size_flags_horizontal = 0

[node name="Expand" type="Button" parent="VBox/Toolbar"]
layout_mode = 2
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="Collapse" type="Button" parent="VBox/Toolbar"]
layout_mode = 2
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="Sep" type="ColorRect" parent="VBox/Toolbar"]
custom_minimum_size = Vector2(2, 0)
Expand All @@ -50,11 +50,11 @@ text = "All:"

[node name="ExpandAll" type="Button" parent="VBox/Toolbar"]
layout_mode = 2
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="CollapseAll" type="Button" parent="VBox/Toolbar"]
layout_mode = 2
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="Sep2" type="ColorRect" parent="VBox/Toolbar"]
custom_minimum_size = Vector2(2, 0)
Expand All @@ -77,13 +77,13 @@ text = "Sync:"
layout_mode = 2
toggle_mode = true
button_pressed = true
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="ScrollOutput" type="Button" parent="VBox/Toolbar"]
layout_mode = 2
toggle_mode = true
button_pressed = true
icon = SubResource("ImageTexture_ecrrc")
icon = SubResource("ImageTexture_8u17l")

[node name="Output" type="Panel" parent="VBox"]
self_modulate = Color(1, 1, 1, 0.541176)
Expand Down
2 changes: 1 addition & 1 deletion addons/gut/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="Gut"
description="Unit Testing tool for Godot."
author="Butch Wesley"
version="9.0.0"
version="9.0.1"
script="gut_plugin.gd"
3 changes: 3 additions & 0 deletions addons/gut/script_parser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class ParsedMethod:
func is_black_listed():
return BLACKLIST.find(_meta.name) != -1

func is_accessor():
return _meta.name.begins_with('@') and \
(_meta.name.ends_with('_getter') or _meta.name.ends_with('_setter'))

func to_s():
var s = _meta.name + "("
Expand Down
2 changes: 1 addition & 1 deletion addons/gut/test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ func replace_node(base_node, path_or_node, with_this):
var to_replace = base_node.get_node(path)
var parent = to_replace.get_parent()
var replace_name = to_replace.get_name()

parent.remove_child(to_replace)
parent.add_child(with_this)
with_this.set_name(replace_name)
Expand Down
2 changes: 1 addition & 1 deletion addons/gut/utils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var ThingCounter = load('res://addons/gut/thing_counter.gd')
var GutScene = load('res://addons/gut/GutScene.tscn')

# Source of truth for the GUT version
var version = '9.0.0'
var version = '9.0.1'
# The required Godot version as an array.
var req_godot = [4, 0, 0]

Expand Down
73 changes: 73 additions & 0 deletions scratch/override_getset.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
extends SceneTree


class HasAccessors:
var normal_accessors = 'default' :
get:
print('@normal_accessors_getter')
return normal_accessors
set(val):
print('@normal_accessors_setter')
print(' = ', normal_accessors)
normal_accessors = val
print(' = ', normal_accessors)

var accessor_methods = 'default' :
get = _get_accessor_methods,
set = _set_accessor_methods

func _get_accessor_methods():
print('[base] _get_accessor_methods')
return accessor_methods

func _set_accessor_methods(val):
print('[base] _set_accessor_methods')
print(' = ', accessor_methods)
accessor_methods = val
print(' = ', accessor_methods)

func set(property, value):
print('!!!!!!!!!!!!! in set')
super.set(property, value)

func get(property):
print('!!!!!!!!!!!!! in get')
return super.get(property)


class OverridesAccessorMethods:
extends HasAccessors

func _get_accessor_methods():
print('[override] _get_accessor_methods')
return super._get_accessor_methods()

func _set_accessor_methods(val):
print('[override] _set_accessor_methods')
super._set_accessor_methods(val)

# ------------------------------------------------------------------------------

func set_some_values(thing):
print('-- Setting normal_accessors')
thing.normal_accessors = 'hello'
print()
print('-- Setting accessor_methods')
thing.accessor_methods = 'world'
print()
print('-- Setting with set/get')
thing.set('accessor_methods', 'hello world')
print(thing.get('accessor_methods'))


func _init():
print("starting")

var h = HasAccessors.new()
set_some_values(h)
print("\n\n")
var o = OverridesAccessorMethods.new()
set_some_values(o)

print("done")
quit();
1 change: 1 addition & 0 deletions test/integration/test_doubler_and_stubber.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extends "res://addons/gut/test.gd"


class BaseTest:
extends GutTest
var Stubber = load('res://addons/gut/stubber.gd')
Expand Down
Loading

0 comments on commit 6e8dca6

Please sign in to comment.