Commit 42cfe48f authored by Rob Pike's avatar Rob Pike

use the new %U format for runes

R=rsc
CC=golang-dev
https://golang.org/cl/3483041
parent 53eaf40e
......@@ -3139,7 +3139,7 @@ out:
c = yyTok2[1] /* unknown char */
}
if yyDebug >= 3 {
fmt.Printf("lex %.4x %s\n", uint(yychar), yyTokname(c))
fmt.Printf("lex %U %s\n", uint(yychar), yyTokname(c))
}
return c
}
......
......@@ -275,10 +275,10 @@ func TestRuneIO(t *testing.T) {
size := utf8.EncodeRune(b[n:], r)
nbytes, err := buf.WriteRune(r)
if err != nil {
t.Fatalf("WriteRune(U+%.4x) error: %s", r, err)
t.Fatalf("WriteRune(%U) error: %s", r, err)
}
if nbytes != size {
t.Fatalf("WriteRune(U+%.4x) expected %d, got %d", r, size, nbytes)
t.Fatalf("WriteRune(%U) expected %d, got %d", r, size, nbytes)
}
n += size
}
......@@ -295,7 +295,7 @@ func TestRuneIO(t *testing.T) {
size := utf8.EncodeRune(p, r)
nr, nbytes, err := buf.ReadRune()
if nr != r || nbytes != size || err != nil {
t.Fatalf("ReadRune(U+%.4x) got U+%.4x,%d not U+%.4x,%d (err=%s)", r, nr, nbytes, r, size, err)
t.Fatalf("ReadRune(%U) got %U,%d not %U,%d (err=%s)", r, nr, nbytes, r, size, err)
}
}
......@@ -305,11 +305,11 @@ func TestRuneIO(t *testing.T) {
for r := 0; r < NRune; r++ {
r1, size, _ := buf.ReadRune()
if err := buf.UnreadRune(); err != nil {
t.Fatalf("UnreadRune(U+%.4x) got error %q", r, err)
t.Fatalf("UnreadRune(%U) got error %q", r, err)
}
r2, nbytes, err := buf.ReadRune()
if r1 != r2 || r1 != r || nbytes != size || err != nil {
t.Fatalf("ReadRune(U+%.4x) after UnreadRune got U+%.4x,%d not U+%.4x,%d (err=%s)", r, r2, nbytes, r, size, err)
t.Fatalf("ReadRune(%U) after UnreadRune got %U,%d not %U,%d (err=%s)", r, r2, nbytes, r, size, err)
}
}
}
......
......@@ -157,7 +157,7 @@ func parseCategory(line string) (state State) {
char := &chars[point]
char.field = field
if char.codePoint != 0 {
die.Logf("point U+%04x reused\n")
die.Logf("point %U reused\n")
}
char.codePoint = lastChar
char.category = field[FGeneralCategory]
......@@ -167,7 +167,7 @@ func parseCategory(line string) (state State) {
// Decimal digit
_, err := strconv.Atoi(field[FNumericValue])
if err != nil {
die.Log("U+%04x: bad numeric field: %s", point, err)
die.Log("%U: bad numeric field: %s", point, err)
}
case "Lu":
char.letter(field[FCodePoint], field[FSimpleLowercaseMapping], field[FSimpleTitlecaseMapping])
......@@ -208,7 +208,7 @@ func (char *Char) letterValue(s string, cas string) int {
v, err := strconv.Btoui64(s, 16)
if err != nil {
char.dump(cas)
die.Logf("U+%04x: bad letter(%s): %s", char.codePoint, s, err)
die.Logf("%U: bad letter(%s): %s", char.codePoint, s, err)
}
return int(v)
}
......
......@@ -21,7 +21,7 @@ func TestScanForwards(t *testing.T) {
for i, expect := range runes {
got := str.At(i)
if got != expect {
t.Errorf("%s[%d]: expected %c (U+%04x); got %c (U+%04x)", s, i, expect, expect, got, got)
t.Errorf("%s[%d]: expected %c (%U); got %c (%U)", s, i, expect, expect, got, got)
}
}
}
......@@ -39,7 +39,7 @@ func TestScanBackwards(t *testing.T) {
expect := runes[i]
got := str.At(i)
if got != expect {
t.Errorf("%s[%d]: expected %c (U+%04x); got %c (U+%04x)", s, i, expect, expect, got, got)
t.Errorf("%s[%d]: expected %c (%U); got %c (%U)", s, i, expect, expect, got, got)
}
}
}
......@@ -63,7 +63,7 @@ func TestRandomAccess(t *testing.T) {
expect := runes[i]
got := str.At(i)
if got != expect {
t.Errorf("%s[%d]: expected %c (U+%04x); got %c (U+%04x)", s, i, expect, expect, got, got)
t.Errorf("%s[%d]: expected %c (%U); got %c (%U)", s, i, expect, expect, got, got)
}
}
}
......
......@@ -58,11 +58,11 @@ func TestFullRune(t *testing.T) {
m := utf8map[i]
b := []byte(m.str)
if !FullRune(b) {
t.Errorf("FullRune(%q) (rune %04x) = false, want true", b, m.rune)
t.Errorf("FullRune(%q) (%U) = false, want true", b, m.rune)
}
s := m.str
if !FullRuneInString(s) {
t.Errorf("FullRuneInString(%q) (rune %04x) = false, want true", s, m.rune)
t.Errorf("FullRuneInString(%q) (%U) = false, want true", s, m.rune)
}
b1 := b[0 : len(b)-1]
if FullRune(b1) {
......@@ -172,7 +172,7 @@ func TestIntConversion(t *testing.T) {
i := 0
for _, r := range ts {
if r != runes[i] {
t.Errorf("%q[%d]: expected %c (U+%04x); got %c (U+%04x)", ts, i, runes[i], runes[i], r, r)
t.Errorf("%q[%d]: expected %c (%U); got %c (%U)", ts, i, runes[i], runes[i], r, r)
}
i++
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment