Skip to content

testing: should panic(nil) cause a test to fail? #6546

@gopherbot

Description

@gopherbot

by elazarl:

package main_test

import "testing"

func TestMe(t *testing) {
    panic(nil)
    t.FailNow()
}

What is the expected output?

Test should fail or panic


What do you see instead?

Test pass


Which compiler are you using (5g, 6g, 8g, gccgo)?

8g


Which operating system are you using?

Mac OS X


Which version are you using?  (run 'go version')

1.1, same in 1.2

Please provide any additional information below.

panic(nil) makes little sense actually, since you cannot distinguish whether a recover()
has no panic, or a nil panic. At any rate, we should make sure panic(nil) never occurred
during testing, in case someone mistakenly throw a nil panic during the test.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions