Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/Unit/test_mod_hook_preprocessor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,26 @@ func test_process_script() -> void:
var result_b_expected: String = load("res://test_mod_hook_preprocessor/test_script_B_processed.gd").source_code.trim_prefix("#")
var result_c := hook_pre_processor.process_script("res://test_mod_hook_preprocessor/test_script_C.gd", true)
var result_c_expected: String = load("res://test_mod_hook_preprocessor/test_script_C_processed.gd").source_code.trim_prefix("#")
# Same as C - only with spaces instead of tabs
var result_d := hook_pre_processor.process_script("res://test_mod_hook_preprocessor/test_script_D.gd", true)
var result_d_expected: String = load("res://test_mod_hook_preprocessor/test_script_D_processed.gd").source_code.trim_prefix("#")

assert_eq(result_a, result_a_expected)
assert_eq(result_b, result_b_expected)
assert_eq(result_c, result_c_expected)
assert_eq(result_d, result_d_expected)


func test_process_script_speed() -> void:
var hook_pre_processor := _ModLoaderModHookPreProcessor.new()
hook_pre_processor.process_begin()

var start_tick := Time.get_ticks_msec()

var result = hook_pre_processor.process_script("res://test_mod_hook_preprocessor/test_script_speed.gd")

var end_tick := Time.get_ticks_msec()

print("Hook Processing took %s msec." % str(end_tick - start_tick))

assert_true((end_tick - start_tick) < 1000)
227 changes: 227 additions & 0 deletions test/test_mod_hook_preprocessor/test_script_D.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
class_name ModHookPreprocessorTestScriptD
extends Node

var six: set = actual_setter
#var six: set = set_exclude_me
var seven: set= actual_setter, get = actually_get_something
var eight: get = actually_get_something, set= actual_setter
var nine: int: set= actual_setter, get = actually_get_something
var thirteen: int: set= actual_setter ,get = actually_get_something
var ten: Array[String]: get = actually_get_something, set= actual_setter
var eleven: = 4 #set= set_exclude_me, get = get_exclude_me
var twelve: set= actual_setter#, get = get_exclude_me
var four10: get = actually_get_something, set= actual_setter
var _5teen: get = actually_get_something, set= actual_setter
var _16: get = actually_get_something, set= actual_setter
var _seven_teen: get = actually_get_something, set= actual_setter
var eighteen: get = actually_get_something, \
set= actual_setter

@export var one : Vector2 = Vector2.ZERO :
set(value):
one = value
print("")
pass
get_groups()
get:
return one

var two: int = 0:
set(v): two = v

var three: int = 0:
get: return three + 5

var four: int = 0:
get: return three + 6

var five:
get:
set_something()
return five *2
set (value):
one = value
print("")
pass
get_groups()


func _ready() -> void:
pass


func method(
one, #Some comment
two, three: int, # More comments
four
):
pass


func super_something():
pass


func super_something_else():
print("oy")


func sup_func_two(): pass


func sup_func():
pass


#func other_test_func(some_param: Cool):
#pass # test if comments match
func other_test_func():
pass


func hello_hello() -> void:
pass


func hellohello(hello: String) -> void: # Hello? hello! hello()
pass


func hello_hello_2 # Hellow
(testing: String)\
-> String:
return ""


func hello() -> void:
pass


func hello_again() -> void:
pass


#func more_comment_testing(some_param: Cool) -> void:
#pass # test if comments match
# func more_comment_testing(some_param: Cool) -> void:
#pass # test if comments match
func more_comment_testing() -> void:
pass


static func static_super():
pass


func this_is_so_cursed
():
pass


func this_too\
():
pass


# func please_stop()
#func please_stop()
# func please_stop()
# func please_stop()
func please_stop\
#func please_stop(some_param: CoolClass)
# func please_stop(some_param: CoolClass) wow (
# wow ()
#( wow
\
():
pass


func why_would_you(put: int, \
backslashes := "\\", in_here := "?!\n"
):
pass


class SomeTestingSubclass:
# check that we are not getting inner funcs with the same name
func get_something():
return "something"

func set_something():
pass


func param_super(one: int, two: String) -> int:
return one


func other_param_super(one: int, two: String) -> int:
return one


func get_something():
return "something"


func set_something():
pass


func actually_get_something():
pass


func actual_setter(val):
six = val


func set_exclude_me():
pass


func get_exclude_me():
pass


func definitely_a_coroutine(args := []):
await tree_entered


func definitely_a_coroutine2(args := []):
var callback := func():
print("test")
return await callback.callv(args)


func definitely_a_coroutine3(args := []):
var callback := func():
print("test")
return await callback.callv([self] + args)


func definitely_a_coroutine4(args := []):
await get_tree().create_timer(1).timeout


func absolutely_not_a_coroutine(args := []):
get_something() # await is a keyword
pass


func definitely_a_coroutine5(args := []):
print("# hello", await get_something())


func definitely_a_coroutine6(args := []):
print(""" test
# hello""", await get_something())


func absolutely_not_a_coroutine2(args := []):
print(""" test
# hello""", get_something()) # don't await


func definitely_a_coroutine7(args := []):
print("# \'hello", await get_something())
Loading
Loading