-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathdialect.go
58 lines (45 loc) · 1.31 KB
/
dialect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package gherkin
import messages "github.com/cucumber/messages/go/v24"
type Dialect struct {
Language string
Name string
Native string
Keywords map[string][]string
KeywordTypes map[string]messages.StepKeywordType
}
func (g *Dialect) FeatureKeywords() []string {
return g.Keywords["feature"]
}
func (g *Dialect) RuleKeywords() []string {
return g.Keywords["rule"]
}
func (g *Dialect) ScenarioKeywords() []string {
return g.Keywords["scenario"]
}
func (g *Dialect) StepKeywords() []string {
result := g.Keywords["given"]
result = append(result, g.Keywords["when"]...)
result = append(result, g.Keywords["then"]...)
result = append(result, g.Keywords["and"]...)
result = append(result, g.Keywords["but"]...)
return result
}
func (g *Dialect) BackgroundKeywords() []string {
return g.Keywords["background"]
}
func (g *Dialect) ScenarioOutlineKeywords() []string {
return g.Keywords["scenarioOutline"]
}
func (g *Dialect) ExamplesKeywords() []string {
return g.Keywords["examples"]
}
func (g *Dialect) StepKeywordType(keyword string) messages.StepKeywordType {
return g.KeywordTypes[keyword]
}
type DialectProvider interface {
GetDialect(language string) *Dialect
}
type gherkinDialectMap map[string]*Dialect
func (g gherkinDialectMap) GetDialect(language string) *Dialect {
return g[language]
}