[Seaside] Bug in Set backtracking
David Shaffer
cdshaffer at acm.org
Wed Oct 19 20:20:54 UTC 2005
Avi Bryant wrote:
>
>
>
> I'm pretty sure that you also need to override #restoreFromSnapshot:
> to do a full #copy as well. Otherwise after a restore, the
> snapshot's internal state will #== the original's internal state, so
> that when you backtrack a *second* time you'll have issues.
>
> Avi
>
Ah yes, thanks. Attached. I also added another test case to
demonstrate this problem...
David
-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 19 October 2005 at 4:18:44 pm'!
!Set methodsFor: '*seaside2' stamp: 'cds 10/19/2005 16:17'!
restoreFromSnapshot: anObject
1 to: self class instSize do: [:i | self instVarAt: i put: (anObject instVarAt: i) copy].
self class isVariable ifTrue: [1 to: self size do: [:i | self at: i put: (anObject at: i) copy]].
! !
-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 19 October 2005 at 4:20:39 pm'!
SCComponentTestCase subclass: #SCSetBacktrackingTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'SeasideTesting-Examples'!
!SCSetBacktrackingTest methodsFor: 'tests' stamp: 'cds 10/17/2005 23:22'!
testAdd
| form input |
self newApplicationWithRootClass: SCSetBacktrackingComponent.
self establishSession.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
self assert: (self component set includes: 'entry1')! !
!SCSetBacktrackingTest methodsFor: 'tests' stamp: 'cds 10/17/2005 23:22'!
testRemove
| form input |
self newApplicationWithRootClass: SCSetBacktrackingComponent.
self establishSession.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
self assert: (self component set includes: 'entry1').
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'remove').
self deny: (self component set includes: 'entry1').
! !
!SCSetBacktrackingTest methodsFor: 'tests' stamp: 'cds 10/19/2005 16:14'!
testSequence1
| form input |
self newApplicationWithRootClass: SCSetBacktrackingComponent.
self establishSession.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry2'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry3'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
self assert: (self component set includesAllOf: (Array with: 'entry1' with: 'entry2' with: 'entry3')).
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'remove').
self deny: (self component set includes: 'entry1').
self back.
self backAndRefresh.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'remove').
self deny: (self component set includes: 'entry1').
! !
!SCSetBacktrackingTest methodsFor: 'tests' stamp: 'cds 10/19/2005 16:16'!
testSequence2
| form input |
self newApplicationWithRootClass: SCSetBacktrackingComponent.
self establishSession.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry2'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry3'.
self submitForm: form pressingButton: (form buttonWithValue: 'add').
self assert: (self component set includesAllOf: (Array with: 'entry1' with: 'entry2' with: 'entry3')).
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'remove').
self deny: (self component set includes: 'entry1').
self back.
self backAndRefresh.
form := self lastResponse forms first.
input := form textInputWithId: 'input'.
input value: 'entry1'.
self submitForm: form pressingButton: (form buttonWithValue: 'remove').
self deny: (self component set includes: 'entry1').
self backAndRefresh.
self assert: (self component set includes: 'entry1')
! !
More information about the Seaside
mailing list