}
func TestDraw(t *testing.T) {
-loop: for _, test := range drawTests {
+loop:
+ for _, test := range drawTests {
dst := hgradRed(255)
// Draw the (src, mask, op) onto a copy of dst using a slow but obviously correct implementation.
golden := makeGolden(dst, test)
i++
// flags and widths
p.fmt.clearflags()
- F: for ; i < end; i++ {
+ F:
+ for ; i < end; i++ {
switch format[i] {
case '#':
p.fmt.sharp = true
}
x := p.parseOperand()
-L: for {
+L:
+ for {
switch p.tok {
case token.PERIOD:
x = p.parseSelectorOrTypeAssertion(p.checkExpr(x))
// a "correcting" unindent immediately following a line break
// is applied before the line break if there is no comment
// between (see writeWhitespace)
- p.print(unindent)
+ p.print(unindent, s.Pos())
p.expr(s.Label, multiLine)
- p.print(token.COLON, vtab, indent)
- if _, isEmpty := s.Stmt.(*ast.EmptyStmt); isEmpty && !nextIsRBrace {
- p.print(token.SEMICOLON)
- break
+ p.print(token.COLON, indent)
+ if _, isEmpty := s.Stmt.(*ast.EmptyStmt); isEmpty {
+ if !nextIsRBrace {
+ p.print(newline, s.Stmt.Pos(), token.SEMICOLON)
+ break
+ }
+ } else {
+ p.print(newline)
}
- p.linebreak(s.Stmt.Pos().Line, 0, 1, ignore, true)
p.stmt(s.Stmt, nextIsRBrace, multiLine)
case *ast.ExprStmt:
// Formatting around labels.
func _() {
L:
-
}
func _() {
switch 0 {
case 0:
- L0: ; // semicolon required
+ L0: // semicolon required
+ ;
case 1:
- L1: ; // semicolon required
+ L1: // semicolon required
+ ;
default:
L2: // no semicolon needed
}
}
+func _() {
+ f()
+L1:
+ f()
+L2:
+ ;
+L3:
+}
+
+
func _() {
// this comment should be indented
L:
-
}
func _() {
-L: _ = 0
+L:
+ _ = 0
}
func _() {
// this comment should be indented
-L: _ = 0
+L:
+ _ = 0
}
func _() {
for {
- L1: _ = 0
+ L1:
+ _ = 0
L2:
_ = 0
}
func _() {
// this comment should be indented
for {
- L1: _ = 0
+ L1:
+ _ = 0
L2:
_ = 0
}
}
_ = 0
-L: _ = 0
+L:
+ _ = 0
}
}
+func _() {
+ f()
+L1:
+ f()
+L2:
+ ;
+L3:
+}
+
+
func _() {
// this comment should be indented
L:
// Loop, parsing hex numbers followed by colon.
j := 0
-L: for j < IPv6len {
+L:
+ for j < IPv6len {
// Hex number.
n, i1, ok := xtoi(s, i)
if !ok || n > 0xFFFF {
var fi int // field index
n := 0 // number of matching fields at depth fd
-L: for i, _ := range t.fields {
+L:
+ for i, _ := range t.fields {
f := t.Field(i)
d := inf
switch {