1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // This file contains tests for the deepequalerrors checker.
17 func (myError) Error() string { return "" }
19 func bad() error { return nil }
36 reflect.DeepEqual(bad(), e) // want `avoid using reflect.DeepEqual with errors`
37 reflect.DeepEqual(io.EOF, io.EOF) // want `avoid using reflect.DeepEqual with errors`
38 reflect.DeepEqual(e, &e) // want `avoid using reflect.DeepEqual with errors`
39 reflect.DeepEqual(e, m) // want `avoid using reflect.DeepEqual with errors`
40 reflect.DeepEqual(e, s1{}) // want `avoid using reflect.DeepEqual with errors`
41 reflect.DeepEqual(e, [1]error{}) // want `avoid using reflect.DeepEqual with errors`
42 reflect.DeepEqual(e, map[error]int{}) // want `avoid using reflect.DeepEqual with errors`
43 reflect.DeepEqual(e, map[int]error{}) // want `avoid using reflect.DeepEqual with errors`
44 // We catch the next not because *os.PathError implements error, but because it contains
45 // a field Err of type error.
46 reflect.DeepEqual(&os.PathError{}, io.EOF) // want `avoid using reflect.DeepEqual with errors`
51 reflect.ValueOf(4) // not reflect.DeepEqual
52 reflect.DeepEqual(3, 4) // not errors
53 reflect.DeepEqual(5, io.EOF) // only one error
54 reflect.DeepEqual(myError(1), io.EOF) // not types that implement error