Commit d7bd43d7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 85e32cdc
......@@ -29,6 +29,7 @@ import (
"context"
"fmt"
"math"
"reflect"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/transaction"
......@@ -648,7 +649,7 @@ func vOid(xvalue interface{}) (zodb.Oid, error) {
// xidOf return string representation of object xid.
func xidOf(obj zodb.IPersistent) string {
if obj == nil {
if obj == nil || reflect.ValueOf(obj).IsNil() {
return "ø"
}
xid := zodb.Xid{At: obj.PJar().At(), Oid: obj.POid()}
......
......@@ -505,7 +505,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
X := exc.Raiseif
var kadjTracked SetKey = nil
var δT map[Key]Δstring = nil
var δT, δTok map[Key]Δstring = nil, nil
// badf queues error message to be reported on return.
var badv []string
......@@ -515,7 +515,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
defer func() {
if badv != nil {
emsg := fmt.Sprintf("%s ; tracked=%v :\n\n", subj, initialTrackedKeys)
emsg += fmt.Sprintf("d12: %v\nδT: %v\n\n", d12, δT)
emsg += fmt.Sprintf("d12: %v\nδTok: %v\nδT: %v\n\n", d12, δTok, δT)
emsg += fmt.Sprintf("kadj[Tracked]: %v\nkadj: %v\n\n", kadjTracked, kadj)
emsg += strings.Join(badv, "\n")
emsg += "\n"
......@@ -570,10 +570,10 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// k ∈ δT <=>
// k ∈ U kadj[·]
// ·∈tracking
inδTOK := SetKey{} // all keys that should be present in δT
for k := range d12 {
δTok = map[Key]Δstring{} // d12[all keys that should be present in δT]
for k,δv := range d12 {
if kadjTracked.Has(k) {
inδTOK.Add(k)
δTok[k] = δv
}
}
......@@ -589,10 +589,10 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// XXX verify δbtail index consistency against @at2
// assert δB.ByRoot == {treeRoot -> ...} if inδTOK != ø
// == ø if inδTOK == ø
// assert δB.ByRoot == {treeRoot -> ...} if δTok != ø
// == ø if δTok == ø
rootsOK := SetOid{}
if len(inδTOK) > 0 {
if len(δTok) > 0 {
rootsOK.Add(treeRoot)
}
roots := SetOid{}
......@@ -600,7 +600,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
roots.Add(root)
}
if !reflect.DeepEqual(roots, rootsOK) {
badf("δB: roots != rootsOK ; inδTOK=%v roots=%v rootsOK=%v", inδTOK, roots, rootsOK)
badf("δB: roots != rootsOK ; roots=%v rootsOK=%v", roots, rootsOK)
return
}
......@@ -618,25 +618,26 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
for _, k := range sortedKeys(δT) {
_, ind12 := d12[k]
if !ind12 {
badf("δT: [%v] is not in d12", k)
badf("δT[%v] ∉ d12", k)
}
}
// k ∈ tracked set -> must be present in δT
// k ∉ tracked set -> may be present in δT (kadj gives exact answer)
for _, k := range sortedKeys(d12) {
_, inδT := δT[k]
if inδT && !inδTOK.Has(k) {
badf("δT: [%v] is extra", k)
_, inδT := δT[k]
_, inδTok := δTok[k]
if inδT && !inδTok {
badf("δT[%v] ∉ δTok", k)
}
if !inδT && inδTOK.Has(k) {
badf("δT: [%v] is missing", k)
if !inδT && inδTok {
badf("δT ∌ δTok[%v]", k)
}
if inδT {
if δT[k] != d12[k] {
badf("δT[%v] != d12[%v]", k, k)
badf("δT[%v] ≠ δTok[%v]", k, k)
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment