From 4c0cd750f1992a0c0bd95b158de2333366521b0a Mon Sep 17 00:00:00 2001 From: gedi Date: Wed, 10 Jun 2015 14:28:56 +0300 Subject: [PATCH] golang 1.5 reference compat issue --- behat.go | 5 +++++ gherkin/ast_test.go | 23 +++++++++++++++++++++++ gherkin/parse.go | 3 ++- gherkin/util_test.go | 23 +---------------------- 4 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 behat.go create mode 100644 gherkin/ast_test.go diff --git a/behat.go b/behat.go new file mode 100644 index 0000000..7905807 --- /dev/null +++ b/behat.go @@ -0,0 +1,5 @@ +package main + +func main() { + +} diff --git a/gherkin/ast_test.go b/gherkin/ast_test.go new file mode 100644 index 0000000..52059a0 --- /dev/null +++ b/gherkin/ast_test.go @@ -0,0 +1,23 @@ +package gherkin + +import ( + "testing" + + "github.com/l3pp4rd/go-behat/gherkin/lexer" +) + +func (a *AST) assertMatchesTypes(expected []lexer.TokenType, t *testing.T) { + key := -1 + for item := a.head; item != nil; item = item.next { + key += 1 + if len(expected) <= key { + t.Fatalf("there are more tokens in AST then expected, next is '%s'", item.value.Type) + } + if expected[key] != item.value.Type { + t.Fatalf("expected ast token '%s', but got '%s' at position: %d", expected[key], item.value.Type, key) + } + } + if len(expected)-1 != key { + t.Fatalf("expected ast length %d, does not match actual: %d", len(expected), key+1) + } +} diff --git a/gherkin/parse.go b/gherkin/parse.go index 4a28054..77a40a2 100644 --- a/gherkin/parse.go +++ b/gherkin/parse.go @@ -168,7 +168,8 @@ func (p *parser) parseFeature() (ft *Feature, err error) { } // there may be tags before scenario - sc := &Scenario{Tags: ft.Tags} + sc := &Scenario{} + sc.Tags = append(sc.Tags, ft.Tags...) if tok.Type == lexer.TAGS { for _, t := range p.parseTags() { if !sc.Tags.Has(t) { diff --git a/gherkin/util_test.go b/gherkin/util_test.go index f61d57f..28f5e8c 100644 --- a/gherkin/util_test.go +++ b/gherkin/util_test.go @@ -1,27 +1,6 @@ package gherkin -import ( - "strings" - "testing" - - "github.com/l3pp4rd/go-behat/gherkin/lexer" -) - -func (a *AST) assertMatchesTypes(expected []lexer.TokenType, t *testing.T) { - key := -1 - for item := a.head; item != nil; item = item.next { - key += 1 - if len(expected) <= key { - t.Fatalf("there are more tokens in AST then expected, next is '%s'", item.value.Type) - } - if expected[key] != item.value.Type { - t.Fatalf("expected ast token '%s', but got '%s' at position: %d", expected[key], item.value.Type, key) - } - } - if len(expected)-1 != key { - t.Fatalf("expected ast length %d, does not match actual: %d", len(expected), key+1) - } -} +import "strings" func indent(n int, s string) string { return strings.Repeat(" ", n) + s