Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1482)

Unified Diff: src/pkg/reflect/all_test.go

Issue 3608041: code review 3608041: reflect: add ArrayType.Slice, ArrayValue.Slice (Closed)
Patch Set: code review 3608041: Right now it's not possible to use the data within a Created 13 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cmd/gc/reflect.c ('k') | src/pkg/reflect/type.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/reflect/all_test.go
===================================================================
--- a/src/pkg/reflect/all_test.go
+++ b/src/pkg/reflect/all_test.go
@@ -375,6 +375,29 @@
}
}
+// Ensure the slice type is available even if never used elsewhere.
+type brandNewType int
+
+func TestArraySlicing(t *testing.T) {
+ va := NewValue([10]brandNewType{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
+ vi := va.(*ArrayValue).Slice(2, 5).Interface()
+ v := NewValue(vi)
+ s := valueToString(v)
+ const want1 = "[]reflect_test.brandNewType{3, 4, 5}"
+ if s != want1 {
+ t.Errorf("Slice: have %#q want %#q", s, want1)
+ }
+
+ va = NewValue([10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
+ vi = va.(*ArrayValue).Slice(2, 5).Interface()
+ v = NewValue(vi)
+ s = valueToString(v)
+ const want2 = "[]int{3, 4, 5}"
+ if s != want2 {
+ t.Errorf("Slice: have %#q want %#q", s, want2)
+ }
+}
+
func TestPtrPointTo(t *testing.T) {
var ip *int32
var i int32 = 1234
« no previous file with comments | « src/cmd/gc/reflect.c ('k') | src/pkg/reflect/type.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b