Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More tests for removed values and two transactions #480

Merged
merged 2 commits into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,44 @@ SoilIndexedDictionaryTest >> testDo [
self assert: counter equals: 2
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testDoWithTransAction [
| tx tx1 tx2 counter |

tx := soil newTransaction.
tx root: dict.
dict at: 1 put: #bar1.
dict at: 2 put: #bar2.
tx commit.
"open a second transaction ..."
tx1 := soil newTransaction.
tx2 := soil newTransaction.

counter := 0.
tx2 root do: [ :each |
self assert: (each beginsWith: 'bar').
counter := counter + 1].
self assert: counter equals: 2.

tx2 root removeKey: 1.

counter := 0.
tx2 root do: [ :each |
self assert: (each beginsWith: 'bar').
counter := counter + 1].
self assert: counter equals: 1.

tx2 commit.
"in tx1 the key is not removed, do: correcty uses the restorValue"
counter := 0.
tx1 root do: [ :each |
self assert: (each beginsWith: 'bar').
counter := counter + 1].
self assert: counter equals: 2


]

{ #category : #tests }
SoilIndexedDictionaryTest >> testFirst [
dict at: #foo2 put: #bar2.
Expand Down Expand Up @@ -409,6 +447,28 @@ SoilIndexedDictionaryTest >> testRemoveKeyIfAbsentWithTransaction [

]

{ #category : #tests }
SoilIndexedDictionaryTest >> testRemoveKeyWithTwoTransactions [

| tx tx2 |
tx := soil newTransaction.
tx root: dict.
dict at: 1 put: #one.
dict at: 2 put: #two.
tx commit.
"we create two transactions"
tx := soil newTransaction.
tx2 := soil newTransaction.
"remove the key"
tx2 root removeKey: 2.
tx2 commit.
"check that we can still see in the first tr"
self assert: (tx root at: 2) equals: #two.
"but removeKey: does not see it, to be fixed"
self flag: #TODO.
"tx root removeKey: 2"
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testSecond [
dict at: #foo put: #bar.
Expand Down