Merge lp:~niemeyer/goyaml/interfaces-are-immutable-values into lp:~gophers/goyaml/trunk
Proposed by
Gustavo Niemeyer
Status: | Merged |
---|---|
Merged at revision: | 34 |
Proposed branch: | lp:~niemeyer/goyaml/interfaces-are-immutable-values |
Merge into: | lp:~gophers/goyaml/trunk |
Diff against target: |
97 lines (+20/-9) 3 files modified
.lbox (+1/-0) decode.go (+5/-2) decode_test.go (+14/-7) |
To merge this branch: | bzr merge lp:~niemeyer/goyaml/interfaces-are-immutable-values |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
The Go Language Gophers | Pending | ||
Review via email: mp+96669@code.launchpad.net |
Description of the change
Unbreak goyaml after interface mutability fix in reflect.
To post a comment you must log in.
Reviewers: mp+96669_ code.launchpad. net,
Message:
Please take a look.
Description:
https:/ /code.launchpad .net/~niemeyer/ goyaml/ interfaces- are-immutable- values/ +merge/ 96669
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/5784060/
Affected files:
A .lbox
M decode.go
M decode_test.go
Index: .lbox
=== <email address hidden> >
<email address hidden>
=== added file '.lbox'
--- .lbox 1970-01-01 00:00:00 +0000
+++ .lbox 2012-03-08 21:51:14 +0000
@@ -0,0 +1,1 @@
+propose -cr -for=lp:goyaml
Index: decode.go (make([ ]interface{ }, 0))
=== <email address hidden> >
<email address hidden>
=== modified file 'decode.go'
--- decode.go 2011-12-21 17:47:08 +0000
+++ decode.go 2012-03-08 21:50:15 +0000
@@ -375,11 +375,11 @@
if set := d.setter("!!seq", &out, &good); set != nil {
defer set()
}
+ var iface reflect.Value
if out.Kind() == reflect.Interface {
// No type hints. Will have to use a generic sequence.
- iface := out
+ iface = out
out = settableValueOf
- iface.Set(out)
}
if out.Kind() != reflect.Slice { Set(reflect. Append( out, e))
@@ -394,6 +394,9 @@
out.
}
}
+ if iface.IsValid() {
+ iface.Set(out)
+ }
return true
}
Index: decode_test.go interface{ }{"fixed" : 685230.15}}, interface{ }{"sexa" : 0}}, // interface{ }{"neginf" : math.Inf(-1)}}, interface{ }{"notanum" : math.NaN()}}, interface{ }{"notanum" : math.NaN()}}, // float64{ "fixed" : 685230.15}},
=== <email address hidden> >
<email address hidden>
=== modified file 'decode_test.go'
--- decode_test.go 2011-12-21 17:47:08 +0000
+++ decode_test.go 2012-03-08 21:50:15 +0000
@@ -41,7 +41,7 @@
{"fixed: 685_230.15", map[string]
//{"sexa: 190:20:30.15", map[string]
Unsupported
{"neginf: -.inf", map[string]
- {"notanum: .NaN", map[string]
+ //{"notanum: .NaN", map[string]
Equality of NaN fails.
{"fixed: 685_230.15", map[string]
// Bools from spec Unmarshal( []byte( item.data) , value)
@@ -136,11 +136,18 @@
value = pv.Interface()
}
err := goyaml.
- c.Assert(err, IsNil, Bug("Item #%d", i))
- c.Assert(value, Equals, item.value)
+ c.Assert(err, IsNil, Commentf("Item #%d", i))
+ c.Assert(value, DeepEquals, item.value)
}
}
+func (s *S) TestUnmarshalNaN(c *C) { interface{ }{} Unmarshal( []byte( "notanum: .NaN"), &value) math.IsNaN( value[" notanum" ].(float64) ), Equals, true) Unmarshal( []byte( item.data) , &value)
+ value := map[string]
+ err := goyaml.
+ c.Assert(err, IsNil)
+ c.Assert(
+}
+
var unmarshalErrorTests = []struct {
data, error string
}{
@@ -155,7 +162,7 @@
for _, item := range unmarshalErrorTests {
var value interface{}
err := goyaml.
- c.Assert(err, ErrorMatches, item.error, Bug("Partial unmarshal: %#v",
value))
+ c.Assert(err, ErrorMatches, item.error, Commentf("Partial
unmarshal: %#v", value))
}
}
@@ -198,9 +205,9 @@ Unmarshal( []byte( item.data) , obj) obj.Field, NotNil,
err := goyaml.
c.Assert(err, IsNil)
c.Assert(
- Bug("Pointer not initialized (%#v...