cgo, goyacc, go/build, html, http, path, path/filepath, testing/quick, test: use rune
Nothing terribly interesting here.
R=golang-dev, bradfitz, gri, r
CC=golang-dev
https://golang.org/cl/5300043
diff --git a/test/convlit.go b/test/convlit.go
index 90ac549..2e3b15b 100644
--- a/test/convlit.go
+++ b/test/convlit.go
@@ -36,7 +36,7 @@
var good4 float64 = 1e20
// explicit conversion of string is okay
-var _ = []int("abc")
+var _ = []rune("abc")
var _ = []byte("abc")
// implicit is not
@@ -47,20 +47,20 @@
type Tstring string
var ss Tstring = "abc"
-var _ = []int(ss)
+var _ = []rune(ss)
var _ = []byte(ss)
// implicit is still not
-var _ []int = ss // ERROR "cannot use|incompatible|invalid"
+var _ []rune = ss // ERROR "cannot use|incompatible|invalid"
var _ []byte = ss // ERROR "cannot use|incompatible|invalid"
// named slice is not
-type Tint []int
+type Trune []rune
type Tbyte []byte
-var _ = Tint("abc") // ERROR "convert|incompatible|invalid"
+var _ = Trune("abc") // ERROR "convert|incompatible|invalid"
var _ = Tbyte("abc") // ERROR "convert|incompatible|invalid"
// implicit is still not
-var _ Tint = "abc" // ERROR "cannot use|incompatible|invalid"
+var _ Trune = "abc" // ERROR "cannot use|incompatible|invalid"
var _ Tbyte = "abc" // ERROR "cannot use|incompatible|invalid"
diff --git a/test/fixedbugs/bug204.go b/test/fixedbugs/bug204.go
index d4534c2..adf0aaf 100644
--- a/test/fixedbugs/bug204.go
+++ b/test/fixedbugs/bug204.go
@@ -7,18 +7,18 @@
package main
func main() {
- nchar := 0;
- a := []int { '日', '本', '語', 0xFFFD };
+ nchar := 0
+ a := []rune{'日', '本', '語', 0xFFFD}
for _, char := range "日本語\xc0" {
if nchar >= len(a) {
- println("BUG");
- break;
+ println("BUG")
+ break
}
if char != a[nchar] {
- println("expected", a[nchar], "got", char);
- println("BUG");
- break;
+ println("expected", a[nchar], "got", char)
+ println("BUG")
+ break
}
- nchar++;
+ nchar++
}
}
diff --git a/test/ken/string.go b/test/ken/string.go
index cbedad4..b74bd7d 100644
--- a/test/ken/string.go
+++ b/test/ken/string.go
@@ -95,7 +95,7 @@
}
/* create string with int array */
- var z2 [3]int
+ var z2 [3]rune
z2[0] = 'a'
z2[1] = '\u1234'
z2[2] = 'c'
diff --git a/test/range.go b/test/range.go
index 91ccd63..8411945 100644
--- a/test/range.go
+++ b/test/range.go
@@ -172,7 +172,7 @@
}
func teststring() {
- s := 0
+ var s rune
nmake = 0
for _, v := range makestring() {
s += v
@@ -208,7 +208,7 @@
func makemap() map[int]int {
nmake++
- return map[int]int{0:'a', 1:'b', 2:'c', 3:'d', 4:'☺'}
+ return map[int]int{0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: '☺'}
}
func testmap() {
diff --git a/test/solitaire.go b/test/solitaire.go
index c789bf2..473a1d1 100644
--- a/test/solitaire.go
+++ b/test/solitaire.go
@@ -14,7 +14,7 @@
// The board must be surrounded by 2 illegal fields in each direction
// so that move() doesn't need to check the board boundaries. Periods
// represent illegal fields, ● are pegs, and ○ are holes.
-var board = []int(
+var board = []rune(
`...........
...........
....●●●....
@@ -28,7 +28,6 @@
...........
`)
-
// center is the position of the center hole if there is a single one;
// otherwise it is -1.
var center int
@@ -46,7 +45,6 @@
}
}
-
var moves int // number of times move is called
// move tests if there is a peg at position pos that can jump over another peg
@@ -63,7 +61,6 @@
return false
}
-
// unmove reverts a previously executed valid move.
func unmove(pos, dir int) {
board[pos] = '●'
@@ -71,7 +68,6 @@
board[pos+2*dir] = '○'
}
-
// solve tries to find a sequence of moves such that there is only one peg left
// at the end; if center is >= 0, that last peg must be in the center position.
// If a solution is found, solve prints the board after each move in a backward
@@ -110,7 +106,6 @@
return false
}
-
func main() {
if !solve() {
println("no solution found")
diff --git a/test/string_lit.go b/test/string_lit.go
index 4358dd8..c702a05 100644
--- a/test/string_lit.go
+++ b/test/string_lit.go
@@ -35,14 +35,14 @@
}
const (
- gx1 = "aä本☺"
- gx2 = "aä\xFF\xFF本☺"
+ gx1 = "aä本☺"
+ gx2 = "aä\xFF\xFF本☺"
gx2fix = "aä\uFFFD\uFFFD本☺"
)
var (
- gr1 = []int(gx1)
- gr2 = []int(gx2)
+ gr1 = []rune(gx1)
+ gr2 = []rune(gx2)
gb1 = []byte(gx1)
gb2 = []byte(gx2)
)
@@ -93,26 +93,26 @@
// test large runes. perhaps not the most logical place for this test.
var r int32
- r = 0x10ffff; // largest rune value
+ r = 0x10ffff // largest rune value
s = string(r)
assert(s, "\xf4\x8f\xbf\xbf", "largest rune")
r = 0x10ffff + 1
s = string(r)
assert(s, "\xef\xbf\xbd", "too-large rune")
- assert(string(gr1), gx1, "global ->[]int")
- assert(string(gr2), gx2fix, "global invalid ->[]int")
+ assert(string(gr1), gx1, "global ->[]rune")
+ assert(string(gr2), gx2fix, "global invalid ->[]rune")
assert(string(gb1), gx1, "->[]byte")
assert(string(gb2), gx2, "global invalid ->[]byte")
var (
- r1 = []int(gx1)
- r2 = []int(gx2)
+ r1 = []rune(gx1)
+ r2 = []rune(gx2)
b1 = []byte(gx1)
b2 = []byte(gx2)
)
- assert(string(r1), gx1, "->[]int")
- assert(string(r2), gx2fix, "invalid ->[]int")
+ assert(string(r1), gx1, "->[]rune")
+ assert(string(r2), gx2fix, "invalid ->[]rune")
assert(string(b1), gx1, "->[]byte")
assert(string(b2), gx2, "invalid ->[]byte")
diff --git a/test/stringrange.go b/test/stringrange.go
index d5ada26..924022b 100644
--- a/test/stringrange.go
+++ b/test/stringrange.go
@@ -14,23 +14,24 @@
func main() {
s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx"
- expect := []int{ 0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x' }
+ expect := []rune{0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x'}
offset := 0
- var i, c int
+ var i int
+ var c rune
ok := true
cnum := 0
for i, c = range s {
- rune, size := utf8.DecodeRuneInString(s[i:len(s)]) // check it another way
+ r, size := utf8.DecodeRuneInString(s[i:len(s)]) // check it another way
if i != offset {
fmt.Printf("unexpected offset %d not %d\n", i, offset)
ok = false
}
- if rune != expect[cnum] {
- fmt.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i, rune, expect[cnum])
+ if r != expect[cnum] {
+ fmt.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i, r, expect[cnum])
ok = false
}
if c != expect[cnum] {
- fmt.Printf("unexpected rune %d from range: %x not %x\n", i, rune, expect[cnum])
+ fmt.Printf("unexpected rune %d from range: %x not %x\n", i, r, expect[cnum])
ok = false
}
offset += size
diff --git a/test/utf.go b/test/utf.go
index a93fc29..ed8a983 100644
--- a/test/utf.go
+++ b/test/utf.go
@@ -9,7 +9,7 @@
import "utf8"
func main() {
- var chars [6] int
+ var chars [6]rune
chars[0] = 'a'
chars[1] = 'b'
chars[2] = 'c'
@@ -21,16 +21,22 @@
s += string(chars[i])
}
var l = len(s)
- for w, i, j := 0,0,0; i < l; i += w {
- var r int
+ for w, i, j := 0, 0, 0; i < l; i += w {
+ var r rune
r, w = utf8.DecodeRuneInString(s[i:len(s)])
- if w == 0 { panic("zero width in string") }
- if r != chars[j] { panic("wrong value from string") }
+ if w == 0 {
+ panic("zero width in string")
+ }
+ if r != chars[j] {
+ panic("wrong value from string")
+ }
j++
}
// encoded as bytes: 'a' 'b' 'c' e6 97 a5 e6 9c ac e8 aa 9e
const L = 12
- if L != l { panic("wrong length constructing array") }
+ if L != l {
+ panic("wrong length constructing array")
+ }
a := make([]byte, L)
a[0] = 'a'
a[1] = 'b'
@@ -44,11 +50,15 @@
a[9] = 0xe8
a[10] = 0xaa
a[11] = 0x9e
- for w, i, j := 0,0,0; i < L; i += w {
- var r int
+ for w, i, j := 0, 0, 0; i < L; i += w {
+ var r rune
r, w = utf8.DecodeRune(a[i:L])
- if w == 0 { panic("zero width in bytes") }
- if r != chars[j] { panic("wrong value from bytes") }
+ if w == 0 {
+ panic("zero width in bytes")
+ }
+ if r != chars[j] {
+ panic("wrong value from bytes")
+ }
j++
}
}