forked from tychofreeman/go-gherkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
step.go
57 lines (48 loc) · 1.19 KB
/
step.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
package gherkin
import (
"bytes"
"fmt"
)
type step struct {
line string
orig string
keys []string
mldata []map[string]string
isPending bool
errors bytes.Buffer
hasErrors bool
}
func (s step) String() string {
return s.line
}
func StepFromString(in string) step{
return step{ line : in, keys: []string{}, mldata : []map[string]string{} }
}
func StepFromStringAndOrig(in, orig string) step{
return step{ line : in, orig: orig, keys: []string{}, mldata : []map[string]string{} }
}
func (s *step) addMlData(line map[string]string) {
s.mldata = append(s.mldata, line)
}
func (s *step) recoverPending() {
if rec := recover(); rec != nil {
if rec == "Pending" {
s.isPending = true
} else {
panic(rec)
}
}
}
func (currStep *step) executeStepDef(steps []stepdef) bool {
defer currStep.recoverPending()
for _, stepd := range steps {
if stepd.execute(currStep, &currStep.errors) {
return true
}
}
fmt.Fprintf(&currStep.errors, `Could not find step definition for "%s"` + "\n", currStep.orig)
return false
}
func (s *step) setMlKeys(keys []string) {
s.keys = keys
}