1
0
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:
Robert Griesemer 2012-10-05 08:48:23 -07:00
parent 1065c6f65a
commit 1f6fba2d56
3 changed files with 59 additions and 1 deletions

View File

@ -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
}
}

View File

@ -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

View File

@ -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{