Skip to content

Support for decl tests and unnamed tests #2

@freakmangd

Description

@freakmangd

test "add" works, but the other two tests don't.

fn add(a: anytype, b: anytype) @TypeOf(a, b) {
    return a + b;
}

test "add" {
    try std.testing.expectEqual(3, add(1, 2));
}

test add {
    try std.testing.expectEqual(3, add(1, 2));
}

test {
    try std.testing.expectEqual(3, add(1, 2));
}

We can get test add working just by changing this line:

@@ -61,7 +61,7 @@ function M.discover_positions(path)
        local query = [[
                ;;query
                (TestDecl
-                       (STRINGLITERALSINGLE) @test.name
+                       [(IDENTIFIER) (STRINGLITERALSINGLE)] @test.name
                ) @test.definition
        ]]
        log.debug("Running query", query)

I couldn't figure out a way to capture unnamed tests, but that's mainly because I'm unfamiliar with the system, I'm sure its doable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions