Skip to content

Imbalance in function source opening/closing shown in markdown/html reports #2208

@ScottFreeCode

Description

@ScottFreeCode

This is a bit of an edge case since normally test functions are not named (in the sense of the function itself having a name) and one does not usually compress the body of the function due to readability/structure, but for what it's worth, this code...

var assert = require("assert")

it("has the head of the function but not the closing brace", function opening() {
    assert(true)
})
it("does the same thing with a function declared elsewhere", functionDeclaredOutside)
it("has the closing brace of the function but not the head", function () {assert(true)}) // a space before the parens doesn't affect it, must be the name
it("does not have the closing brace because of just one space after the contents", function() {assert(true) })
it("has the closing brace if the function body is entirely empty", function()
    {}
)
it("does not have the closing brace because of just one space in the body",function(){ })

function functionDeclaredOutside() {
    assert(true)
}

...yields this output when run with the markdown reporter...


has the head of the function but not the closing brace.

function opening() {
    assert(true)

does the same thing with a function declared elsewhere.

function functionDeclaredOutside() {
    assert(true)

has the closing brace of the function but not the head.

assert(true)}

does not have the closing brace because of just one space after the contents.

assert(true)

has the closing brace if the function body is entirely empty.

}

does not have the closing brace because of just one space in the body.


I would guess that the inclusion of function name() { in named functions is intentional, so that references to the name from within the function are clear; but in any case the closing brace being included or not should match whether the function name/opening is included, rather than whether there's whitespace before it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions