From 5b37259155e91f01f35fe0d18d6d5eef8d15bcb1 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Wed, 30 Nov 2022 14:29:53 -0800 Subject: [PATCH] [TreeDictionary] merge: Add missing invariant checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The lack of these calls allowed our tests to pass even though the implementation is failing to properly update the count. D’oh! This and the previous commits adds a myriad new test failures. --- .../TreeDictionary/TreeDictionary+Merge.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Merge.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Merge.swift index b3cf7d44..17e600a2 100644 --- a/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Merge.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Merge.swift @@ -43,7 +43,8 @@ extension TreeDictionary { uniquingKeysWith combine: (Value, Value) throws -> Value ) rethrows { _invalidateIndices() - try _root.merge(.top, keysAndValues._root, combine) + _ = try _root.merge(.top, keysAndValues._root, combine) + _invariantCheck() } /// Merges the key-value pairs in the given sequence into the dictionary, @@ -87,6 +88,7 @@ extension TreeDictionary { } } } + _invariantCheck() } /// Merges the key-value pairs in the given sequence into the dictionary,