Home | History | Annotate | Download | only in fixedbugs
      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 
      7 package main
      8 
      9 import (
     10 	"fmt"
     11 	"strings"
     12 )
     13 
     14 type ET struct{}
     15 
     16 func (*ET) Error() string { return "err" }
     17 
     18 func 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 
     29 func 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