Skip to content

Commit

Permalink
Merge pull request #484 from ApptiveGrid/Tests-10-17
Browse files Browse the repository at this point in the history
Index: test #isEmpty, fix BTree
  • Loading branch information
noha authored Oct 18, 2023
2 parents ad91774 + eec1dbf commit 77e8168
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 46 deletions.
42 changes: 0 additions & 42 deletions src/Soil-Core-Tests/SoilIndexTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,45 +120,3 @@ SoilIndexTest >> testFlushIndexPages [


]

{ #category : #tests }
SoilIndexTest >> testIndexCreation [
| tx dict obj1 obj2 |
tx := soil newTransaction.
obj1 := Object new.
tx makeRoot: obj1.
obj2 := Object new.
tx makeRoot: obj2.
dict := SoilSkipListDictionary new
keySize: 32;
maxLevel: 8.
tx root: dict.
dict
at: #foo put: obj1;
at: #boo put: obj2.
tx commit.

]

{ #category : #tests }
SoilIndexTest >> testIndexCreationAndRead [
| tx dict obj1 obj2 tx2 |
tx := soil newTransaction.
obj1 := SoilTestClusterRoot new nested: 'object1'.
tx makeRoot: obj1.
obj2 := SoilTestClusterRoot new nested: 'object2'.
tx makeRoot: obj2.
dict := SoilSkipListDictionary new
keySize: 8;
maxLevel: 4.
tx root: dict.
dict
at: #foo put: obj1;
at: #boo put: obj2.
tx commit.
tx2 := soil newTransaction.
self assert: (tx2 root at: #foo) nested equals: 'object1'.
self assert: (tx2 root at: #boo) nested equals: 'object2'


]
75 changes: 72 additions & 3 deletions src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ SoilIndexedDictionaryTest >> testAtIndexWithTransaction [

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testConcurrentIsEmpty [
| tx1 tx2 tx3 |
tx1 := soil newTransaction.
tx1 root: (dict
at: #one put: #onevalue;
yourself).
tx1 commit.
tx2 := soil newTransaction.
"After creating tx2 we open a concurrent transaction and add a key to
the dictionary which should be invisible to tx2"
tx3 := soil newTransaction.
tx3 root removeKey: #one.
tx3 commit.
self assert: tx2 root size equals: 0.
self assert: tx2 root isEmpty.
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testDo [
| counter |
Expand Down Expand Up @@ -298,11 +316,62 @@ SoilIndexedDictionaryTest >> testFirstWithTransaction [

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testIndexCreation [
| tx obj1 obj2 |
tx := soil newTransaction.
obj1 := Object new.
tx makeRoot: obj1.
obj2 := Object new.
tx makeRoot: obj2.
tx root: dict.
dict
at: #foo put: obj1;
at: #boo put: obj2.
tx commit

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testIndexCreationAndRead [
| tx obj1 obj2 tx2 |
tx := soil newTransaction.
obj1 := SoilTestClusterRoot new nested: 'object1'.
tx makeRoot: obj1.
obj2 := SoilTestClusterRoot new nested: 'object2'.
tx makeRoot: obj2.
tx root: dict.
dict
at: #foo put: obj1;
at: #boo put: obj2.
tx commit.
tx2 := soil newTransaction.
self assert: (tx2 root at: #foo) nested equals: 'object1'.
self assert: (tx2 root at: #boo) nested equals: 'object2'


]

{ #category : #tests }
SoilIndexedDictionaryTest >> testIsEmpty [
self assert: dict isEmpty.
dict at: #foo put: #bar.
self deny: dict isEmpty
| tx tx1 tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: 1 put: #one.
tx commit.
"open a second transaction ..."
tx1 := soil newTransaction.
"and test isEmpty"
self deny: tx1 root isEmpty.

tx2 := soil newTransaction.
tx2 root removeKey: 1.
self assert: tx2 root size equals: 0.
self assert: tx2 root isEmpty.
tx2 commit.
"still not empty in t1"
self assert: tx1 root size equals: 1.
self deny: tx1 root isEmpty.
]

{ #category : #tests }
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilBTreeDataPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SoilBTreeDataPage >> find: aKey with: aBTree [

{ #category : #testing }
SoilBTreeDataPage >> hasItems [
^ items notEmpty
^ (items reject: [ :each | each value isRemoved ]) notEmpty
]

{ #category : #utilities }
Expand Down

0 comments on commit 77e8168

Please sign in to comment.