mirror of
https://github.com/golang/go
synced 2024-11-26 11:28:21 -07:00
go/printer: don't forget the .0 in 1.0
(use floating-point rather then integer constant division) gofmt -w src misc Fixes #3965. R=r, bsiegert, 0xjnml CC=bradfitz, golang-dev https://golang.org/cl/6610051
This commit is contained in:
parent
1065c6f65a
commit
1f6fba2d56
@ -203,7 +203,7 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
|
||||
} else {
|
||||
const r = 4 // threshold
|
||||
ratio := float64(size) / float64(prevSize)
|
||||
useFF = ratio <= 1/r || r <= ratio
|
||||
useFF = ratio <= 1.0/r || r <= ratio
|
||||
}
|
||||
}
|
||||
|
||||
|
29
src/pkg/go/printer/testdata/declarations.golden
vendored
29
src/pkg/go/printer/testdata/declarations.golden
vendored
@ -654,6 +654,35 @@ var _ = map[int]int{
|
||||
abcde: a, // align with previous line
|
||||
}
|
||||
|
||||
// alignment of map composite entries: test cases from issue 3965
|
||||
// aligned
|
||||
var _ = T1{
|
||||
a: x,
|
||||
b: y,
|
||||
cccccccccccccccccccc: z,
|
||||
}
|
||||
|
||||
// not aligned
|
||||
var _ = T2{
|
||||
a: x,
|
||||
b: y,
|
||||
ccccccccccccccccccccc: z,
|
||||
}
|
||||
|
||||
// aligned
|
||||
var _ = T3{
|
||||
aaaaaaaaaaaaaaaaaaaa: x,
|
||||
b: y,
|
||||
c: z,
|
||||
}
|
||||
|
||||
// not aligned
|
||||
var _ = T4{
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: x,
|
||||
b: y,
|
||||
c: z,
|
||||
}
|
||||
|
||||
func _() {
|
||||
var _ = T{
|
||||
a, // must introduce trailing comma
|
||||
|
29
src/pkg/go/printer/testdata/declarations.input
vendored
29
src/pkg/go/printer/testdata/declarations.input
vendored
@ -667,6 +667,35 @@ var _ = map[int]int{
|
||||
abcde: a, // align with previous line
|
||||
}
|
||||
|
||||
// alignment of map composite entries: test cases from issue 3965
|
||||
// aligned
|
||||
var _ = T1{
|
||||
a: x,
|
||||
b: y,
|
||||
cccccccccccccccccccc: z,
|
||||
}
|
||||
|
||||
// not aligned
|
||||
var _ = T2{
|
||||
a: x,
|
||||
b: y,
|
||||
ccccccccccccccccccccc: z,
|
||||
}
|
||||
|
||||
// aligned
|
||||
var _ = T3{
|
||||
aaaaaaaaaaaaaaaaaaaa: x,
|
||||
b: y,
|
||||
c: z,
|
||||
}
|
||||
|
||||
// not aligned
|
||||
var _ = T4{
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: x,
|
||||
b: y,
|
||||
c: z,
|
||||
}
|
||||
|
||||
|
||||
func _() {
|
||||
var _ = T{
|
||||
|
Loading…
Reference in New Issue
Block a user