ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.54k stars 733 forks source link

[Bug]: Uncovered lines are shown as covered when there are annotations #42605

Open MaryamZi opened 3 weeks ago

MaryamZi commented 3 weeks ago

Description

$title. May be related to annotation closures.

Steps to Reproduce

import ballerina/graphql;

service class Profile {
    private final string name;
    private final int age;

    function init(string name, int age) {
        self.name = name;
        self.age = age;
    }

    resource function get name() returns string {
        return self.name;
    }

    resource function get age() returns int {
        return self.age;
    }

    resource function get isAdult() returns boolean {
        return self.age > 21;
    }

    resource function get reviews() returns Review[] {
        return [
            new (1, "review 1"),
            new (2, "review 2")
        ];
    }
}

annotation MyAnnot on parameter, return, class;

@MyAnnot
service class Review {
    int id;
    string content;

    function init(
            @MyAnnot 
                int id, string content) {
        self.id = id;
        self.content = content;
    }

    resource function get id() returns @MyAnnot int {
        return self.id;
    }

    resource function get content() returns string {
        return self.content;
    }
}

service /graphql on new graphql:Listener(9090) {

    resource function get profile() returns Profile {
        return new ("John Doe", 51);
    }
}

Tests

import ballerina/graphql;
import ballerina/test;

final graphql:Client cl = check new ("http://localhost:9090/graphql");

@test:Config
function testCallOriginal() returns error? {
    json j = check cl->execute(string `{ profile { name isAdult } }`);
    test:assertEquals(j, {"data":{"profile":{"name":"John Doe", "isAdult":true}}});
}

Screenshot from 2024-04-22 11-43-40

Affected Version(s)

2201.9.0-rc1