Skip to content

Commit

Permalink
Merge pull request #53 from ReconfigureIO/feature/empty-funcs
Browse files Browse the repository at this point in the history
Add support for empty func definitions.
  • Loading branch information
bohde authored Jan 23, 2018
2 parents a30b3f8 + 1fb9d9c commit 1223666
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fmt:
go fmt -x ./...

test: fmt
go test -v $$(go list ./... | grep -v /vendor/ | grep -v /cmd/)
go test -v $$(go list ./... | grep -v /vendor/ | grep -v /cmd/ | grep -v /fixtures/)

PACKAGES := $(shell find ./* -type d | grep -v vendor)

Expand Down
6 changes: 6 additions & 0 deletions fixtures/packages/emptyfunc/empty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

func foo()

func main() {
}
66 changes: 66 additions & 0 deletions fixtures/packages/emptyfunc/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"kind" : "file",
"name" : {
"position" : {
"filename" : "fixtures/packages/emptyfunc/empty.go",
"offset" : 8,
"line" : 1,
"column" : 9
},
"value" : "main",
"kind" : "ident"
},
"imports" : [],
"declarations" : [
{
"type" : "function",
"position" : {
"filename" : "fixtures/packages/emptyfunc/empty.go",
"column" : 1,
"line" : 3,
"offset" : 14
},
"body" : null,
"comments" : [],
"name" : {
"position" : {
"column" : 6,
"line" : 3,
"offset" : 19,
"filename" : "fixtures/packages/emptyfunc/empty.go"
},
"kind" : "ident",
"value" : "foo"
},
"params" : [],
"kind" : "decl",
"results" : null
},
{
"comments" : [],
"params" : [],
"kind" : "decl",
"name" : {
"position" : {
"filename" : "fixtures/packages/emptyfunc/empty.go",
"offset" : 31,
"line" : 5,
"column" : 6
},
"value" : "main",
"kind" : "ident"
},
"results" : null,
"type" : "function",
"position" : {
"filename" : "fixtures/packages/emptyfunc/empty.go",
"column" : 1,
"line" : 5,
"offset" : 26
},
"body" : []
}
],
"all-comments" : [],
"comments" : []
}
3 changes: 3 additions & 0 deletions goblin.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@ func DumpStmt(s ast.Stmt, fset *token.FileSet) interface{} {
}

func DumpBlock(b *ast.BlockStmt, fset *token.FileSet) []interface{} {
if b == nil {
return nil
}
results := make([]interface{}, len(b.List))
for i, v := range b.List {
results[i] = DumpStmt(v, fset)
Expand Down
5 changes: 5 additions & 0 deletions goblin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func TestPackageFixtures(t *testing.T) {
"fixtures/packages/interface_type/interface.go",
"fixtures/packages/interface_type/interface.json",
},
Fixture{
"empty function",
"fixtures/packages/emptyfunc/empty.go",
"fixtures/packages/emptyfunc/empty.json",
},
}

for _, fix := range fixtures {
Expand Down

0 comments on commit 1223666

Please sign in to comment.