1
0
mirror of https://github.com/golang/go synced 2024-11-05 16:46:10 -07:00
go/cmd/stringer/testdata/gap.go
Rob Pike d0448f16e3 go.tools/cmd/stringer: add end-to-end test that compiles, runs, and verifies the generated method
In the process, fix a bug in one of the method generators.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/141130043
2014-09-05 15:42:23 -07:00

45 lines
713 B
Go

// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Gaps and an offset.
package main
import "fmt"
type Gap int
const (
Two Gap = 2
Three Gap = 3
Five Gap = 5
Six Gap = 6
Seven Gap = 7
Eight Gap = 8
Nine Gap = 9
Eleven Gap = 11
)
func main() {
ck(0, "Gap(0)")
ck(1, "Gap(1)")
ck(Two, "Two")
ck(Three, "Three")
ck(4, "Gap(4)")
ck(Five, "Five")
ck(Six, "Six")
ck(Seven, "Seven")
ck(Eight, "Eight")
ck(Nine, "Nine")
ck(10, "Gap(10)")
ck(Eleven, "Eleven")
ck(12, "Gap(12)")
}
func ck(gap Gap, str string) {
if fmt.Sprint(gap) != str {
panic("gap.go: " + str)
}
}