Permalink
Browse files

Revert SliceOf usage, since that is not actually in go1 and the usage…

… is not essential
  • Loading branch information...
robfig committed Jan 13, 2013
1 parent 8e08d09 commit cba1a4038eca58e798978b67d20f1b55a42108a1
Showing with 10 additions and 31 deletions.
  1. +1 −6 controller.go
  2. +0 −3 harness/reflect.go
  3. +9 −22 harness/reflect_test.go
View
@@ -91,12 +91,7 @@ func (c *Controller) Invoke(appControllerPtr reflect.Value, method reflect.Value
if c.Result == nil {
// Invoke the action.
- var resultValue reflect.Value
- if method.Type().IsVariadic() {
- resultValue = method.CallSlice(methodArgs)[0]
- } else {
- resultValue = method.Call(methodArgs)[0]
- }
+ resultValue := method.Call(methodArgs)[0]
if resultValue.Kind() == reflect.Interface && !resultValue.IsNil() {
c.Result = resultValue.Interface().(Result)
}
View
@@ -672,9 +672,6 @@ func NewTypeExpr(pkgName string, expr ast.Expr) TypeExpr {
case *ast.ArrayType:
e := NewTypeExpr(pkgName, t.Elt)
return TypeExpr{"[]" + e.Expr, e.PkgName, e.pkgIndex + 2}
- case *ast.Ellipsis:
- e := NewTypeExpr(pkgName, t.Elt)
- return TypeExpr{"[]" + e.Expr, e.PkgName, e.pkgIndex + 2}
default:
log.Println("Failed to generate name for field.")
ast.Print(nil, expr)
View
@@ -86,33 +86,23 @@ func TestGetValidationKeys(t *testing.T) {
}
var TypeExprs = map[string]TypeExpr{
- "int": TypeExpr{"int", "", 0},
- "*int": TypeExpr{"*int", "", 1},
- "[]int": TypeExpr{"[]int", "", 2},
- "...int": TypeExpr{"[]int", "", 2},
- "[]*int": TypeExpr{"[]*int", "", 3},
- "...*int": TypeExpr{"[]*int", "", 3},
- "MyType": TypeExpr{"MyType", "pkg", 0},
- "*MyType": TypeExpr{"*MyType", "pkg", 1},
- "[]MyType": TypeExpr{"[]MyType", "pkg", 2},
- "...MyType": TypeExpr{"[]MyType", "pkg", 2},
- "[]*MyType": TypeExpr{"[]*MyType", "pkg", 3},
- "...*MyType": TypeExpr{"[]*MyType", "pkg", 3},
+ "int": TypeExpr{"int", "", 0},
+ "*int": TypeExpr{"*int", "", 1},
+ "[]int": TypeExpr{"[]int", "", 2},
+ "[]*int": TypeExpr{"[]*int", "", 3},
+ "MyType": TypeExpr{"MyType", "pkg", 0},
+ "*MyType": TypeExpr{"*MyType", "pkg", 1},
+ "[]MyType": TypeExpr{"[]MyType", "pkg", 2},
+ "[]*MyType": TypeExpr{"[]*MyType", "pkg", 3},
}
func TestTypeExpr(t *testing.T) {
for typeStr, expected := range TypeExprs {
- // Handle arrays and ... myself, since ParseExpr() does not.
+ // Handle arrays myself, since ParseExpr() does not.
array := strings.HasPrefix(typeStr, "[]")
if array {
typeStr = typeStr[2:]
}
-
- ellipsis := strings.HasPrefix(typeStr, "...")
- if ellipsis {
- typeStr = typeStr[3:]
- }
-
expr, err := parser.ParseExpr(typeStr)
if err != nil {
t.Error("Failed to parse test expr:", typeStr)
@@ -122,9 +112,6 @@ func TestTypeExpr(t *testing.T) {
if array {
expr = &ast.ArrayType{expr.Pos(), nil, expr}
}
- if ellipsis {
- expr = &ast.Ellipsis{expr.Pos(), expr}
- }
actual := NewTypeExpr("pkg", expr)
if !reflect.DeepEqual(expected, actual) {

0 comments on commit cba1a40

Please sign in to comment.