Skip to content

Commit 43c03a7

Browse files
authored
Fix functional. (#157)
1 parent 45f8973 commit 43c03a7

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

functional/functional.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ func Run(ctx context.Context, fn TestFunc, opts ...FunctionalOption) bool {
2828
name := funcName(fn)
2929
t := newT(name, opts...)
3030
t.invoke(ctx, fn)
31-
return t.pass
31+
return t.result.Pass
3232
}
3333

3434
// Run a test with user-provided name.
3535
func RunWithName(ctx context.Context, name string, fn TestFunc, opts ...FunctionalOption) bool {
3636
t := newT(name, opts...)
3737
t.invoke(ctx, fn)
38-
return t.pass
38+
return t.result.Pass
3939
}
4040

4141
// Run a suite of tests as a unit.
@@ -67,7 +67,7 @@ func RunSuite(ctx context.Context, suiteName string, tests []TestFunc, opts ...F
6767
}
6868
})
6969

70-
return t.pass
70+
return t.result.Pass
7171
}
7272

7373
// Run a benchmark test. Test named after function name.
@@ -116,5 +116,5 @@ func RunBenchmarkSuiteTimes(ctx context.Context, suiteName string, times int, te
116116
}
117117
})
118118

119-
return b.pass
119+
return b.result.Pass
120120
}

functional/t.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type T struct {
3535
name string
3636
ctx context.Context
3737
deadline time.Time
38-
pass bool
3938
indent int
4039
writer io.Writer
4140
errWriter io.Writer
@@ -83,11 +82,11 @@ func (t *T) Run(name string, fn TestFunc) bool {
8382

8483
t2.invoke(t.ctx, fn)
8584

86-
if !t2.pass {
87-
t.pass = false
85+
if !t2.result.Pass {
86+
t.result.Pass = false
8887
}
8988

90-
return t.pass
89+
return t.result.Pass
9190
}
9291

9392
func (t *T) Deadline() (time.Time, error) {
@@ -99,12 +98,12 @@ func (t *T) Deadline() (time.Time, error) {
9998

10099
func (t *T) Error(args ...any) {
101100
fmt.Fprintln(t.errWriter, args...)
102-
t.pass = false
101+
t.result.Pass = false
103102
}
104103

105104
func (t *T) Errorf(format string, args ...any) {
106105
fmt.Fprintf(t.errWriter, format+"\n", args...)
107-
t.pass = false
106+
t.result.Pass = false
108107
}
109108

110109
func (t *T) FailNow() {

0 commit comments

Comments
 (0)