-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
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.