Val2("if false { i = 2 } else { i = 3 }; i2 = 4", "i", 3, "i2", 4),
Val2("if i == i2 { i = 2 } else { i = 3 }; i2 = 4", "i", 3, "i2", 4),
// Omit optional parts
- Val2("if { i = 2 } else { i = 3 }; i2 = 4", "i", 2, "i2", 4),
+ Val2("if true { i = 2 } else { i = 3 }; i2 = 4", "i", 2, "i2", 4),
Val2("if true { i = 2 }; i2 = 4", "i", 2, "i2", 4),
Val2("if false { i = 2 }; i2 = 4", "i", 1, "i2", 4),
// Init
CErr("fn1 := func() int { if true { return 1 } }", "return"),
CErr("fn1 := func() int { if true { } }", "return"),
Run("fn1 := func() int { if true { }; return 1 }"),
- CErr("fn1 := func() int { if { } }", "return"),
- CErr("fn1 := func() int { if { } else { return 2 } }", "return"),
- Run("fn1 := func() int { if { return 1 } }"),
- Run("fn1 := func() int { if { return 1 } else { } }"),
- Run("fn1 := func() int { if { return 1 } else { } }"),
+ CErr("fn1 := func() int { if true { } }", "return"),
+ CErr("fn1 := func() int { if true { } else { return 2 } }", "return"),
+ Run("fn1 := func() int { if true { return 1 }; return 0 }"),
+ Run("fn1 := func() int { if true { return 1 } else { }; return 0 }"),
+ Run("fn1 := func() int { if true { return 1 } else { }; return 0 }"),
// Switch
Val1("switch { case false: i += 2; case true: i += 4; default: i += 8 }", "i", 1+4),
// Formatting of if-statement headers.
func _() {
- if {
+ if true {
}
- if {
- } // no semicolon printed
if expr {
}
if expr {
- } // no semicolon printed
- if expr {
} // no parens printed
- if expr {
- } // no semicolon and parens printed
- if x := expr; {
+ if x := expr; true {
use(x)
}
if x := expr; expr {
func _() {
switch {
}
- switch {
- } // no semicolon printed
switch expr {
}
switch expr {
- } // no semicolon printed
- switch expr {
} // no parens printed
- switch expr {
- } // no semicolon and parens printed
switch x := expr; {
default:
use(
func _() {
- if {
+ if true {
_ = 0
}
_ = 0 // the indentation here should not be affected by the long label name
AnOverlongLabel:
_ = 0
- if {
+ if true {
_ = 0
}
_ = 0
// Formatting of if-statement headers.
func _() {
- if {}
- if;{} // no semicolon printed
+ if true {}
if expr{}
- if;expr{} // no semicolon printed
if (expr){} // no parens printed
- if;((expr)){} // no semicolon and parens printed
- if x:=expr;{
+ if x:=expr; true {
use(x)}
if x:=expr; expr {use(x)}
}
// Formatting of switch-statement headers.
func _() {
switch {}
- switch;{} // no semicolon printed
switch expr {}
- switch;expr{} // no semicolon printed
switch (expr) {} // no parens printed
- switch;((expr)){} // no semicolon and parens printed
switch x := expr; { default:use(
x)
}
if (((x))) {}
if ([]T{}) {}
if (([]T{})) {}
- if ; (((([]T{})))) {}
+ if (((([]T{})))) {}
for (x) {}
for (((x))) {}
switch (x) {}
switch (((x))) {}
switch ([]T{}) {}
- switch ; (((([]T{})))) {}
+ switch (((([]T{})))) {}
for _ = range ((([]T{T{42}}))) {}
// leave parentheses - composite literals start with a type name
if (T{}) {}
if ((T{})) {}
- if ; ((((T{})))) {}
+ if ((((T{})))) {}
for (T{}) {}
for ((T{})) {}
for ; ((((T{})))) ; {}
switch (T{}) {}
- switch ; ((((T{})))) {}
+ switch ((((T{})))) {}
for _ = range (((T1{T{42}}))) {}
func _() {
- if {
+ if true {
_ = 0
}
_ = 0 // the indentation here should not be affected by the long label name
AnOverlongLabel:
_ = 0
- if {
+ if true {
_ = 0
}
_ = 0