Fix misc:stringify_variables test

This commit is contained in:
JeremyStar™ 2024-04-23 21:02:11 +02:00
parent 7c6feb4caf
commit f8cefc511c
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -159,28 +159,32 @@ func test_get_center() -> void:
# stringify_variables
func test_stringify_variables() -> void:
rskip("Unfinished")
return
# Init CORE
await load_framework()
# Variables
var test_in_string: String = "[b]null[/b]=%null%\n[b]bool[/b]=%bool%\n[b]int[/b]=%int%\n[b]float[/b]=%float%\n[b]string[/b]=%string%\n[b]stringname[/b]=%stringname%\n[b]color[/b]=%color%\n[b]rid[/b]=%rid%\n[b]array[/b]=%array%\n[b]dict[/b]=%dictionary%\n[b]nodepath[/b]=%nodepath%\n[b]call[/b]=%callable%\n[b]signal[/b]=%signal%\n[b]vec2[/b]=%vector2%\n[b]vec2i[/b]=%vector2i%\n[b]rect2[/b]=%rect2%\n[b]rect2i[/b]=%rect2i%\n[b]trans2d[/b]=%transform2d%\n[b]vec3[/b]=%vector3%\n[b]vec3i[/b]=%vector3i%\n[b]plane[/b]=%plane%\n[b]quarternion[/b]=%quaternion%\n[b]aabb[/b]=%aabb%\n[b]trans3d[/b]=%transform3d%\n[b]basis[/b]=%basis%\n[b]projection[/b]=%projection%\n[b]vec4[/b]=%vector4%\n[b]vec4i[/b]=%vector4i%"
var test_in_string: String = "null=%null%\nbool=%bool%\nint=%int%\nfloat=%float%\nstring=%string%\nstringname=%stringname%\ncolor=%color%\narray=%array%\ndict=%dictionary%\nnodepath=%nodepath%\nvec2=%vector2%\nvec2i=%vector2i%\nrect2=%rect2%\nrect2i=%rect2i%\ntrans2d=%transform2d%\nvec3=%vector3%\nvec3i=%vector3i%\nplane=%plane%\nquarternion=%quaternion%\naabb=%aabb%\ntrans3d=%transform3d%\nbasis=%basis%\nprojection=%projection%\nvec4=%vector4%\nvec4i=%vector4i%"
var test_in_args: Dictionary = { "null": null, "bool": true, "int": 505, "float": 505.69, "string": "some string", "stringname": "some string name", "color": Color("#d60532"), "rid": RenderingServer.get_white_texture(), "array": [ "item1", "item2", true, 4 ], "dictionary": { "key0": true, 1: "key2" }, "nodepath": NodePath("/root/CORE"), "callable": func() -> void: pass, "signal": core.logger.log_event, "vector2": Vector2(PI, TAU), "vector2i": Vector2i(505, 69), "rect2": Rect2(1.51, 2.56, 3.89, 4.11), "rect2i": Rect2i(1, 2, 3, 4), "transform2d": Transform2D(1.5, Vector2(2.1, 2.2), 3.6, Vector2(4.1, 4.2)), "vector3": Vector3(59.666, NAN, INF), "vector3i": Vector3i(505, 69, 1713208182), "plane": Plane(Vector3(1.5, 2.5, 3.5), 55.7777), "quaternion": Quaternion(1.55, 2.7812, 3.671, 4.8871), "aabb": AABB(Vector3(1.1, 1.2, 1.3), Vector3(2.1, 2.2, 2.3)), "transform3d": Transform3D(Basis(Vector3(1.11, 1.12, 1.13), Vector3(1.21, 1.22, 1.23), Vector3(1.31, 1.32, 1.33)), Vector3(2.1, 2.2, 2.3)), "basis": Basis(Vector3(1.1358, 1.268718, 1.35818), Vector3(2.1481, 2.258819, 2.3718), Vector3(3.1658581, 3.2581587, 3.357158)), "projection": Projection(Transform3D(Basis(Vector3(1.11, 1.12, 1.13), Vector3(1.21, 1.22, 1.23), Vector3(1.31, 1.32, 1.33)), Vector3(2.1, 2.2, 2.3))), "vector4": Vector4(1.55158, 2.517571, 3.58157, 4.51857185), "vector4i": Vector4i(1, 2, 3, 4) }
var test_out: String = "unfinished"
var test_out: String = "null='null'\nbool='(bool) true'\nint='(int) 505'\nfloat='(float) 505.69'\nstring='(string) \"some string\"'\nstringname='(string) \"some string name\"'\ncolor='(color) r=(int) 214 g=(int) 5 b=(int) 50 a=(int) 255'\narray='(array) [ (string) \"item1\", (string) \"item2\", (bool) true, (int) 4 ]'\ndict='(dictionary) { (string) \"key0\": (bool) true, (int) 1 }'\nnodepath='(nodepath) /root/CORE'\nvec2='(vector2) x=(float) 3.14159274101257 y=(float) 6.28318548202515'\nvec2i='(vector2i) x=(int) 505 y=(int) 69'\nrect2='(rect2) size=(vector2) x=(float) 3.89000010490417 y=(float) 4.1100001335144 pos=(vector2) x=(float) 1.50999999046326 y=(float) 2.55999994277954 end=(vector2) x=(float) 5.40000009536743 y=(float) 6.67000007629395'\nrect2i='(rect2i) size=(vector2i) x=(int) 3 y=(int) 4 pos=(vector2i) x=(int) 1 y=(int) 2 end=(vector2i) x=(int) 4 y=(int) 6'\ntrans2d='(transform2d) x=(vector2) x=(float) 0.14854811131954 y=(float) 2.09473943710327 y=(vector2) x=(float) 2.03679251670837 y=(float) 0.83155089616776 origin=(vector2) x=(float) 4.09999990463257 y=(float) 4.19999980926514'\nvec3='(vector3) x=(float) 59.6660003662109 y=(float) nan z=(float) inf'\nvec3i='(vector3i) x=(int) 505 y=(int) 69 z=(int) 1713208182'\nplane='(plane) x=(float) 1.5 y=(float) 2.5 z=(float) 3.5 d=(float) 55.7776985168457 normal=(vector3) x=(float) 1.5 y=(float) 2.5 z=(float) 3.5'\nquarternion='(quaternion) x=(float) 1.54999995231628 y=(float) 2.78119993209839 z=(float) 3.6710000038147 w=(float) 4.88710021972656'\naabb='(aabb) size=(vector3) x=(float) 2.09999990463257 y=(float) 2.20000004768372 z=(float) 2.29999995231628 pos=(vector3) x=(float) 1.10000002384186 y=(float) 1.20000004768372 z=(float) 1.29999995231628 end=(vector3) x=(float) 3.19999980926514 y=(float) 3.40000009536743 z=(float) 3.59999990463257'\ntrans3d='(transform3d) basis=(basis) x=(vector3) x=(float) 1.11000001430511 y=(float) 1.12000000476837 z=(float) 1.12999999523163 y=(vector3) x=(float) 1.21000003814697 y=(float) 1.22000002861023 z=(float) 1.23000001907349 z=(vector3) x=(float) 1.30999994277954 y=(float) 1.32000005245209 z=(float) 1.33000004291534 origin=(vector3) x=(float) 2.09999990463257 y=(float) 2.20000004768372 z=(float) 2.29999995231628'\nbasis='(basis) x=(vector3) x=(float) 1.13580000400543 y=(float) 1.26871800422668 z=(float) 1.35818004608154 y=(vector3) x=(float) 2.14809989929199 y=(float) 2.25881910324097 z=(float) 2.3717999458313 z=(vector3) x=(float) 3.16585803031921 y=(float) 3.25815868377686 z=(float) 3.35715794563293'\nprojection='(projection) x=(vector4) x=(float) 1.11000001430511 y=(float) 1.12000000476837 z=(float) 1.12999999523163 w=(float) 0 y=(vector4) x=(float) 1.21000003814697 y=(float) 1.22000002861023 z=(float) 1.23000001907349 w=(float) 0 z=(vector4) x=(float) 1.30999994277954 y=(float) 1.32000005245209 z=(float) 1.33000004291534 w=(float) 0 w=(vector4) x=(float) 2.09999990463257 y=(float) 2.20000004768372 z=(float) 2.29999995231628 w=(float) 1'\nvec4='(vector4) x=(float) 1.55157995223999 y=(float) 2.51757097244263 z=(float) 3.58156991004944 w=(float) 4.5185718536377'\nvec4i='(vector4i) x=(int) 1 y=(int) 2 z=(int) 3 w=(int) 4'"
var test_result: String = core.misc.stringify_variables(test_in_string, test_in_args)
if test_result != test_out:
lerror("Got invalid test result:")
lerror("in (string) -> " + test_in_string.replace("\n", "\\n"))
await get_tree().create_timer(1).timeout # output overflow workaround
lerror("in (string) ->")
for line in test_in_string.split("\n"):
print_rich("[color=red]---> " + line + "[/color]")
await get_tree().create_timer(0.05).timeout # output overflow workaround
lerror("in (args) -> " + str(test_in_args))
await get_tree().create_timer(1).timeout # output overflow workaround
lerror("expected -> " + test_out.replace("\n", "\\n"))
await get_tree().create_timer(1).timeout # output overflow workaround
lerror("got -> " + test_result.replace("\n", "\\n"))
await get_tree().create_timer(1).timeout # output overflow workaround
lerror("expected ->")
for line in test_out.split("\n"):
print_rich("[color=red]---> " + line + "[/color]")
await get_tree().create_timer(0.05).timeout # output overflow workaround
lerror("got ->")
for line in test_result.split("\n"):
print_rich("[color=red]---> " + line + "[/color]")
await get_tree().create_timer(0.05).timeout # output overflow workaround
rerror("Test did not return the right value (check logs)")
return
rok()
rok("All types except RIDs, Callables and Signals have been verified as working.")