Skip to content

Commit

Permalink
Merge pull request #10 from aquarhead/match-invoke-comp
Browse files Browse the repository at this point in the history
Add check for mismatch of operations in history
  • Loading branch information
aphyr authored Jun 28, 2021
2 parents 4fd888c + 58523dd commit 1eb532c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/elle/list_append.clj
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,27 @@
:duplicates dups})))))
seq))

(defn op-mismatch
"Given a history, find mismatches of mop invocations to its completion.
They should match exactly except for [:r k nil], which can match any
[:r k v]."
[history]
(->> history
pair-index
; Only take invoke/complete pairs
(filter (fn [[invoke complete]] (= (:type invoke) :invoke)))
; map to vector of mops pairs: (([pair pair]), (pairs), ...)
(map (fn [[invoke complete]] (map vector (:value invoke) (:value complete))))
; -> [([pair pair]), (pairs), ...]
(into [])
(map (partial filter (fn [[invoke complete]]
(not
(if (and (= (first invoke) :r) (= (last invoke) nil))
(and (= (first complete) :r) (= (second invoke) (second complete)))
(= invoke complete))))))
(keep seq)
seq))

(defn merge-orders
"Takes two potentially incompatible read orders (sequences of elements), and
computes a total order which is consistent with both of them: where there are
Expand Down Expand Up @@ -758,6 +779,7 @@
(check {} history))
([opts history]
(let [history (remove (comp #{:nemesis} :process) history)
op-mismatch (op-mismatch history)
g1a (g1a-cases history)
g1b (g1b-cases history)
internal (internal-cases history)
Expand All @@ -778,6 +800,7 @@

; And merge in our own anomalies
anomalies (cond-> cycles
op-mismatch (assoc :op-mismatch op-mismatch)
dups (assoc :duplicate-elements dups)
incmp-order (assoc :incompatible-order incmp-order)
internal (assoc :internal internal)
Expand Down

0 comments on commit 1eb532c

Please sign in to comment.