| 1 | // Copyright 2023 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. |
| 4 | |
| 5 | // This file contains tests for the gofix checker. |
| 6 | |
| 7 | package a |
| 8 | |
| 9 | const one = 1 |
| 10 | |
| 11 | //go:fix inline |
| 12 | const ( |
| 13 | in3 = one |
| 14 | in4 = one |
| 15 | bad1 = 1 // want `invalid //go:fix inline directive: const value is not the name of another constant` |
| 16 | ) |
| 17 | |
| 18 | //go:fix inline |
| 19 | const in5, |
| 20 | in6, |
| 21 | bad2 = one, one, |
| 22 | one + 1 // want `invalid //go:fix inline directive: const value is not the name of another constant` |
| 23 | |
| 24 | //go:fix inline |
| 25 | const ( |
| 26 | a = iota // want `invalid //go:fix inline directive: const value is iota` |
| 27 | b |
| 28 | in7 = one |
| 29 | ) |
| 30 | |
| 31 | func shadow() { |
| 32 | //go:fix inline |
| 33 | const a = iota // want `invalid //go:fix inline directive: const value is iota` |
| 34 | |
| 35 | const iota = 2 |
| 36 | |
| 37 | //go:fix inline |
| 38 | const b = iota // not an error: iota is not the builtin |
| 39 | } |
| 40 | |
| 41 | // Type aliases |
| 42 | |
| 43 | //go:fix inline |
| 44 | type A int // want `invalid //go:fix inline directive: not a type alias` |
| 45 | |
| 46 | //go:fix inline |
| 47 | type E = map[[one]string][]int // want `invalid //go:fix inline directive: array types not supported` |