1// run
2
3// Copyright 2017 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7package main
8
9import (
10	"fmt"
11	"strings"
12)
13
14type ET struct{}
15
16func (*ET) Error() string { return "err" }
17
18func main() {
19	check("false", fmt.Sprintf("(*ET)(nil) == error(nil): %v", (*ET)(nil) == error(nil)))
20	check("true", fmt.Sprintf("(*ET)(nil) != error(nil): %v", (*ET)(nil) != error(nil)))
21
22	nilET := (*ET)(nil)
23	nilError := error(nil)
24
25	check("false", fmt.Sprintf("nilET == nilError: %v", nilET == nilError))
26	check("true", fmt.Sprintf("nilET != nilError: %v", nilET != nilError))
27}
28
29func check(want, gotfull string) {
30	got := gotfull[strings.Index(gotfull, ": ")+len(": "):]
31	if got != want {
32		panic("want " + want + " got " + got + " from " + gotfull)
33	}
34}
35