[Seaside] Ports of Seaside - are there useful modules

Avi Bryant avi@beta4.com
Mon, 22 Apr 2002 17:15:35 -0700 (PDT)


On Mon, 22 Apr 2002, Jeffrey Odell wrote:

> I'd be happy to give it a try in VisualAge - can you post the TestCase?
> And, is this test case a universal case for continuation?  Can I test
> Dolphin, SmallScript, etc. with it?

These are the tests I use - they're pretty ad hoc, but if they don't cause
any walkbacks or infinite loops you know you're doing well.  And, yes, all
they're testing is the semantics of callCC I want, so it should be pretty
universal across dialects.

Note that people that are used to continuations will think these tests are
a little funny; the semantics Seaside wants are not identical to the
typical implementation of call/cc.

---------------------

TestCase subclass: #TestContinuations
	instanceVariableNames: 'tmp tmp2 '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Kernel-Methods'!

!TestContinuations methodsFor: 'tests'!

testSimplestCallCC
	|x|
	x := [:cc | cc value: true] callCC.
	self assert: x.!

testSimpleCallCC
	|x continuation|
	x := [:cc | continuation := cc. false] callCC.
	x ifFalse: [continuation value: true].
	self assert: x.!

testMethodTemps
	|i continuation|
	i := 0.
	i := i + ([:cc | continuation := cc. 1] callCC).
	self assert: i ~= 3.
	i = 2 ifFalse: [continuation value: 2].!

testBlockVars
	|continuation a|
	tmp := 0.
	a := [:cc | continuation := cc. 0] callCC.
	tmp := tmp + a.
	tmp2 isNil
		ifFalse: [tmp2 value]
		ifTrue:
			[#(1 2 3) do:
				[:i |
				[:cc | tmp2 := cc.
				continuation value: i] callCC]].
	self assert: tmp = 6.!

testBlockTemps
	|y|
	#(1 2 3) inject: 0 into:
		[:j :i ||x|
			x := i.
			tmp isNil
			  ifTrue: [tmp2 := [:cc | tmp := cc. [:q]] callCC].
			tmp2 value: x.
			x := 17].
	y := [:cc | tmp value: cc. 42] callCC.
	self assert: y = 1.! !

-----------------------------------

> My original question was prompted by the fact I have a bunch of code in
> Dolphin I'd like to keep there.  However, I also have some VisualAge
> stuff that would benefit from Seaside.

My initial playing around with Dolphin didn't make me very optimistic
about getting call/cc working - I couldn't even figure out how to get my
hands on the stack.  But I didn't try all that hard.

> I really liked the tutorial, and would be happy to pursue further.

Good luck,
Avi