diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-02 19:34:41 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-02 19:34:41 +0000 |
commit | 506cf9aaead4f5519f5549a918d285365b44e989 (patch) | |
tree | fe0344f264049738dca876a6dd2f69e96621ca17 /libgo/go/xml | |
parent | bfa9b58039ceacb1bae803fbbfb049b93540f2a7 (diff) | |
download | gcc-506cf9aaead4f5519f5549a918d285365b44e989.zip gcc-506cf9aaead4f5519f5549a918d285365b44e989.tar.gz gcc-506cf9aaead4f5519f5549a918d285365b44e989.tar.bz2 |
libgo: Update to weekly.2011-11-01.
From-SVN: r181938
Diffstat (limited to 'libgo/go/xml')
-rw-r--r-- | libgo/go/xml/marshal_test.go | 37 | ||||
-rw-r--r-- | libgo/go/xml/read.go | 2 | ||||
-rw-r--r-- | libgo/go/xml/xml.go | 16 |
3 files changed, 26 insertions, 29 deletions
diff --git a/libgo/go/xml/marshal_test.go b/libgo/go/xml/marshal_test.go index ad3aa97..eb358d5 100644 --- a/libgo/go/xml/marshal_test.go +++ b/libgo/go/xml/marshal_test.go @@ -8,10 +8,10 @@ import ( "reflect" "testing" - "os" "bytes" - "strings" + "os" "strconv" + "strings" ) type DriveType int @@ -314,27 +314,27 @@ func TestMarshal(t *testing.T) { } var marshalErrorTests = []struct { - Value interface{} - ExpectErr string - ExpectKind reflect.Kind + Value interface{} + Err string + Kind reflect.Kind }{ { - Value: make(chan bool), - ExpectErr: "xml: unsupported type: chan bool", - ExpectKind: reflect.Chan, + Value: make(chan bool), + Err: "xml: unsupported type: chan bool", + Kind: reflect.Chan, }, { Value: map[string]string{ "question": "What do you get when you multiply six by nine?", "answer": "42", }, - ExpectErr: "xml: unsupported type: map[string] string", - ExpectKind: reflect.Map, + Err: "xml: unsupported type: map[string] string", + Kind: reflect.Map, }, { - Value: map[*Ship]bool{nil: false}, - ExpectErr: "xml: unsupported type: map[*xml.Ship] bool", - ExpectKind: reflect.Map, + Value: map[*Ship]bool{nil: false}, + Err: "xml: unsupported type: map[*xml.Ship] bool", + Kind: reflect.Map, }, } @@ -342,14 +342,11 @@ func TestMarshalErrors(t *testing.T) { for idx, test := range marshalErrorTests { buf := bytes.NewBuffer(nil) err := Marshal(buf, test.Value) - if got, want := err, test.ExpectErr; got == nil { - t.Errorf("#%d: want error %s", idx, want) - continue - } else if got.String() != want { - t.Errorf("#%d: marshal(%#v) = [error] %q, want %q", idx, test.Value, got, want) + if err == nil || err.String() != test.Err { + t.Errorf("#%d: marshal(%#v) = [error] %q, want %q", idx, test.Value, err, test.Err) } - if got, want := err.(*UnsupportedTypeError).Type.Kind(), test.ExpectKind; got != want { - t.Errorf("#%d: marshal(%#v) = [error kind] %s, want %s", idx, test.Value, got, want) + if kind := err.(*UnsupportedTypeError).Type.Kind(); kind != test.Kind { + t.Errorf("#%d: marshal(%#v) = [error kind] %s, want %s", idx, test.Value, kind, test.Kind) } } } diff --git a/libgo/go/xml/read.go b/libgo/go/xml/read.go index f64e130..1fe20ac 100644 --- a/libgo/go/xml/read.go +++ b/libgo/go/xml/read.go @@ -206,7 +206,7 @@ func fieldName(original string) string { } return strings.Map( - func(x int) int { + func(x rune) rune { if x == '_' || unicode.IsDigit(x) || unicode.IsLetter(x) { return unicode.ToLower(x) } diff --git a/libgo/go/xml/xml.go b/libgo/go/xml/xml.go index 85c24bc..bc03c8e 100644 --- a/libgo/go/xml/xml.go +++ b/libgo/go/xml/xml.go @@ -960,13 +960,13 @@ Input: // Decide whether the given rune is in the XML Character Range, per // the Char production of http://www.xml.com/axml/testaxml.htm, // Section 2.2 Characters. -func isInCharacterRange(rune int) (inrange bool) { - return rune == 0x09 || - rune == 0x0A || - rune == 0x0D || - rune >= 0x20 && rune <= 0xDF77 || - rune >= 0xE000 && rune <= 0xFFFD || - rune >= 0x10000 && rune <= 0x10FFFF +func isInCharacterRange(r rune) (inrange bool) { + return r == 0x09 || + r == 0x0A || + r == 0x0D || + r >= 0x20 && r <= 0xDF77 || + r >= 0xE000 && r <= 0xFFFD || + r >= 0x10000 && r <= 0x10FFFF } // Get name space name: name with a : stuck in the middle. @@ -1690,7 +1690,7 @@ func procInstEncoding(s string) string { if v[0] != '\'' && v[0] != '"' { return "" } - idx = strings.IndexRune(v[1:], int(v[0])) + idx = strings.IndexRune(v[1:], rune(v[0])) if idx == -1 { return "" } |