fix snippet string argument extraction followed by non space character
Этот коммит содержится в:
родитель
6e3b3f764a
коммит
c302697f9e
2 изменённых файлов: 30 добавлений и 2 удалений
|
@ -92,3 +92,29 @@ Feature: undefined step snippets
|
||||||
s.Step(`^the project should be there$`, theProjectShouldBeThere)
|
s.Step(`^the project should be there$`, theProjectShouldBeThere)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Scenario: should handle string argument followed by comma
|
||||||
|
Given a feature "undefined.feature" file:
|
||||||
|
"""
|
||||||
|
Feature: undefined
|
||||||
|
|
||||||
|
Scenario: add item to basket
|
||||||
|
Given there is a "Sith Lord Lightsaber", which costs £5
|
||||||
|
When I add the "Sith Lord Lightsaber" to the basket
|
||||||
|
"""
|
||||||
|
When I run feature suite
|
||||||
|
And the undefined step snippets should be:
|
||||||
|
"""
|
||||||
|
func thereIsAWhichCosts(arg1 string, arg2 int) error {
|
||||||
|
return godog.ErrPending
|
||||||
|
}
|
||||||
|
|
||||||
|
func iAddTheToTheBasket(arg1 string) error {
|
||||||
|
return godog.ErrPending
|
||||||
|
}
|
||||||
|
|
||||||
|
func FeatureContext(s *godog.Suite) {
|
||||||
|
s.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
|
||||||
|
s.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
6
fmt.go
6
fmt.go
|
@ -15,7 +15,9 @@ import (
|
||||||
|
|
||||||
// some snippet formatting regexps
|
// some snippet formatting regexps
|
||||||
var snippetExprCleanup = regexp.MustCompile("([\\/\\[\\]\\(\\)\\\\^\\$\\.\\|\\?\\*\\+\\'])")
|
var snippetExprCleanup = regexp.MustCompile("([\\/\\[\\]\\(\\)\\\\^\\$\\.\\|\\?\\*\\+\\'])")
|
||||||
var snippetExprQuoted = regexp.MustCompile("(\\s*|^)\"(?:[^\"]*)\"(\\s+|$)")
|
|
||||||
|
// var snippetExprQuoted = regexp.MustCompile("(\\s*|^)\"(?:[^\"]*)\"(\\s+|,|:|\\.|$)")
|
||||||
|
var snippetExprQuoted = regexp.MustCompile("(\\W|^)\"(?:[^\"]*)\"(\\W|$)")
|
||||||
var snippetMethodName = regexp.MustCompile("[^a-zA-Z\\_\\ ]")
|
var snippetMethodName = regexp.MustCompile("[^a-zA-Z\\_\\ ]")
|
||||||
var snippetNumbers = regexp.MustCompile("(\\d+)")
|
var snippetNumbers = regexp.MustCompile("(\\d+)")
|
||||||
|
|
||||||
|
@ -346,7 +348,7 @@ func (f *basefmt) snippets() string {
|
||||||
for _, u := range f.undefined {
|
for _, u := range f.undefined {
|
||||||
expr := snippetExprCleanup.ReplaceAllString(u.step.Text, "\\$1")
|
expr := snippetExprCleanup.ReplaceAllString(u.step.Text, "\\$1")
|
||||||
expr = snippetNumbers.ReplaceAllString(expr, "(\\d+)")
|
expr = snippetNumbers.ReplaceAllString(expr, "(\\d+)")
|
||||||
expr = snippetExprQuoted.ReplaceAllString(expr, " \"([^\"]*)\" ")
|
expr = snippetExprQuoted.ReplaceAllString(expr, "$1\"([^\"]*)\"$2")
|
||||||
expr = "^" + strings.TrimSpace(expr) + "$"
|
expr = "^" + strings.TrimSpace(expr) + "$"
|
||||||
|
|
||||||
name := snippetNumbers.ReplaceAllString(u.step.Text, " ")
|
name := snippetNumbers.ReplaceAllString(u.step.Text, " ")
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче