MikeSchulze / gdUnit3

A Godot Unit Test Framework. Support for gdScript and c# unit testing
MIT License
312 stars 22 forks source link

GD-379: Documentation: non existing function `Fuzzers.random_rangei()` in example #379

Closed ACG8 closed 1 year ago

ACG8 commented 1 year ago

Describe the bug On the following documentation page: https://mikeschulze.github.io/gdUnit3/advanced_testing/fuzzing/

The example code snippets for fuzzers makes use of the nonexistent method "random_rangei": func test_fuzzer_inject_value(fuzzer := Fuzzers.random_rangei(-23, 22), fuzzer_iterations = 100):

However, it should instead use the correct method "rangei": func test_fuzzer_inject_value(fuzzer := Fuzzers.rangei(-23, 22), fuzzer_iterations = 100):

There are 4 different code snippets on the page where this error occurs.

Steps to Reproduce Go to https://mikeschulze.github.io/gdUnit3/advanced_testing/fuzzing/

ACG8 commented 1 year ago

Also worth mentioning in case it needs to change, the file GdScriptParserTest.gd (res://addons/gdUnit3/test/core/parse/GdScriptParserTest.gd) is the single place in the project that uses random_rangei, and it is in text being used to create GdFunctionArguments; not sure what the significance of that is (the test does pass).

func test_parse_func_descriptor_with_fuzzers():
    var source_code := """
    func test_foo(fuzzer_a = fuzz_a(), fuzzer_b := fuzz_b(),
        fuzzer_c :Fuzzer = fuzz_c(),
        fuzzer = Fuzzers.random_rangei(-23, 22),
        fuzzer_iterations = 234,
        fuzzer_seed = 100):
    """.split("\n")
    var fs = _parser.extract_func_signature(source_code, 0)
    var fd = _parser.parse_func_description(fs, "class", ["path"], 22)

    assert_that(fd).is_equal(GdFunctionDescriptor.new("test_foo", 22, false, false, false, TYPE_NIL, "", [
        GdFunctionArgument.new("fuzzer_a", "Fuzzer", "fuzz_a()"),
        GdFunctionArgument.new("fuzzer_b", "Fuzzer", "fuzz_b()"),
        GdFunctionArgument.new("fuzzer_c", "Fuzzer", "fuzz_c()"),
        GdFunctionArgument.new("fuzzer", "Fuzzer", "Fuzzers.random_rangei(-23, 22)"),
        GdFunctionArgument.new("fuzzer_iterations", "int", "234"),
        GdFunctionArgument.new("fuzzer_seed", "int", "100")
    ]))
MikeSchulze commented 1 year ago

Hello @ACG8, thank you for figuring this out.

The documentation is not up to date and needs to be corrected.

The test you mentioned is just a test to parse a function signature and uses the deprecated function name which is not bad. It is after all tested on GdFunctionArgument.new("fuzzer", "Fuzzer", "Fuzzers.random_rangei(-23, 22)"), which is ok.

So this is just a documentation issue that needs to be updated.

Thanks for reporting it.