Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
73bc026b
Commit
73bc026b
authored
Jan 24, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d1f63f32
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
18 deletions
+33
-18
go/zodb/δtail.go
go/zodb/δtail.go
+2
-0
go/zodb/δtail_test.go
go/zodb/δtail_test.go
+31
-18
No files found.
go/zodb/δtail.go
View file @
73bc026b
...
...
@@ -82,6 +82,8 @@ func (δtail *ΔTail) Head() Tid {
return
δtail
.
head
}
// XXX + Tail?
// XXX add way to extend coverage without appending changed data? (i.e. if a
// txn did not change file at all) -> but then it is simply .Append(rev, nil)?
...
...
go/zodb/δtail_test.go
View file @
73bc026b
...
...
@@ -25,8 +25,6 @@ import (
"testing"
)
// XXX test Head
func
TestΔTail
(
t
*
testing
.
T
)
{
δtail
:=
NewΔTail
()
...
...
@@ -41,7 +39,7 @@ func TestΔTail(t *testing.T) {
}
// δCheck verifies that δtail state corresponds to provided tailv
δCheck
:=
func
(
tailv
...
δRevEntry
)
{
δCheck
:=
func
(
head
Tid
,
tailv
...
δRevEntry
)
{
t
.
Helper
()
for
i
:=
1
;
i
<
len
(
tailv
);
i
++
{
...
...
@@ -50,6 +48,10 @@ func TestΔTail(t *testing.T) {
}
}
if
h
:=
δtail
.
Head
();
h
!=
head
{
t
.
Fatalf
(
"Head() -> %s ; want %s"
,
h
,
head
)
}
if
!
tailvEqual
(
δtail
.
tailv
,
tailv
)
{
t
.
Fatalf
(
"tailv:
\n
have: %v
\n
want: %v"
,
δtail
.
tailv
,
tailv
)
}
...
...
@@ -85,56 +87,67 @@ func TestΔTail(t *testing.T) {
}
δCheck
()
δCheck
(
0
)
δCheckLastUP
(
4
,
12
,
12
)
// δtail = ø
δAppend
(
R
(
10
,
3
,
5
))
δCheck
(
R
(
10
,
3
,
5
))
δCheck
(
10
,
R
(
10
,
3
,
5
))
δCheckLastUP
(
3
,
9
,
9
)
// at < δtail
δCheckLastUP
(
3
,
12
,
12
)
// at > δtail
δCheckLastUP
(
4
,
10
,
10
)
// id ∉ δtail
δAppend
(
R
(
11
,
7
))
δCheck
(
R
(
10
,
3
,
5
),
R
(
11
,
7
))
δCheck
(
11
,
R
(
10
,
3
,
5
),
R
(
11
,
7
))
δAppend
(
R
(
12
,
7
))
δCheck
(
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
))
δCheck
(
12
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
))
δAppend
(
R
(
14
,
3
,
8
))
δCheck
(
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheck
(
14
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheckLastUP
(
8
,
12
,
10
)
// id ∈ δtail, but has no entry with rev ≤ at
δtail
.
ForgetBefore
(
10
)
δCheck
(
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheck
(
14
,
R
(
10
,
3
,
5
),
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δtail
.
ForgetBefore
(
11
)
δCheck
(
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δCheck
(
14
,
R
(
11
,
7
),
R
(
12
,
7
),
R
(
14
,
3
,
8
))
δtail
.
ForgetBefore
(
13
)
δCheck
(
R
(
14
,
3
,
8
))
δCheck
(
14
,
R
(
14
,
3
,
8
))
δtail
.
ForgetBefore
(
15
)
δCheck
()
δCheck
(
14
)
// Append panics on non-↑ rev
δAppend
(
R
(
15
,
1
))
func
()
{
// δAppendPanic verifies that Append(δ.rev = rev) panics.
δAppendPanic
:=
func
(
rev
Tid
)
{
defer
func
()
{
r
:=
recover
()
if
r
==
nil
{
t
.
Fatal
(
"append non-↑: not panicked"
)
t
.
Fatal
f
(
"append(rev=%s) non-↑: not panicked"
,
rev
)
}
rev
:=
Tid
(
15
)
want
:=
fmt
.
Sprintf
(
"δtail.Append: rev not ↑: %s -> %s"
,
rev
,
rev
)
want
:=
fmt
.
Sprintf
(
"δtail.Append: rev not ↑: %s -> %s"
,
δtail
.
head
,
rev
)
if
r
!=
want
{
t
.
Fatalf
(
"append non-↑:
\n
have: %q
\n
want: %q"
,
r
,
want
)
}
}()
δAppend
(
R
(
rev
))
}
// on empty δtail
δAppendPanic
(
14
)
δAppendPanic
(
13
)
δAppendPanic
(
12
)
// on !empty δtail
δAppend
(
R
(
15
,
1
))
}()
δCheck
(
15
,
R
(
15
,
1
))
δAppendPanic
(
15
)
δAppendPanic
(
14
)
// .tailv underlying storage is not kept after forget
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment