MikeSchulze/gdUnit4

GD-370: Mock a class with functions return type enum results in an error `Parser Error: Cannot return a value of type "null" ..`

Closed this issue · 0 comments

The used GdUnit4 version

4.2.2 (Pre Release/Master branch)

The used Godot version

v4.2.1.stable.official [b09f793f5]

Operating System

Windows, MacOS

Describe the bug

I want to mock a class which contains functions with return type of enum.
The mock is created, but when I try to use the functions with the return type enum it ends up in an error.
Parser Error: Cannot return a value of type "null" as "CustomResourceTestClass.TEST_ENUM".

Steps to Reproduce

Use the example to reproduce

class_name CustomResourceTestClass

enum TEST_ENUM { FOO, BAR}

func get_enum() -> TEST_ENUM:
    return TEST_ENUM.FOO
extends GdUnitTestSuite

func test_test():
    var mock_class = mock(CustomResourceTestClass, CALL_REAL_FUNC)
    assert_that(mock_class.get_enum()).is_equal(CustomResourceTestClass.TEST_ENUM.FOO)

Minimal reproduction project

No response