--------------020900010904050904010400
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

On the way to learn ruby effectively, I have tried to develop the same 
framework as the one described by Peter Seibel in [1]. This was also the 
cause of my questions in [2].

In terms of pure framework, my ruby version is more compact (only 11 
lines of code) and it looks more understandable to me (I'm not really a 
lisper, anyway), although I miss the code”’a feature of lisp somehow.

I know that every test expression is evaluated twice, but I don't mind 
very much about it, unless the double computation can be removed without 
adding new lines of code.

This simple exercise has made me appreciate ruby for its conjunction of 
power and simplicity.

I'd like to have your feedback on the attached version.
Thanks, Giuliano


[1] - http://tinyurl.com/2b99d
[2] - rubytalk:92492  
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/92492

-- 
If you want to send me an email in the address you have to write 'p', 
then a dot, followed by 'bossi' at 'quinary', another dot and 'com' at last

--------------020900010904050904010400
Content-Type: text/plain;
 nameest7.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filenameest7.rb"

def stack
	methods  aller[3..caller.size].collect{|m| m.split(/[`']/).last}
	methods.select {|m| m.index('test_') 0}.reverse.join " "
end
def check(*tests)
	tests.collect! {|t| puts "#{eval(t) ? 'pass' : 'FAIL'} ... (#{stack}) #{t.strip}"; eval(t)}
	combine_results(*tests)
end
def combine_results(*tests)
	tests.inject(true) {|acc, t| acc && t}
end

def test_plus
	check(
		"1 + 2 3", 
		"1 + 2 + 3 6", 
		"-1 + -3 -4")
end
def test_multiply
	check(
		"2 * 2 4",
		"3 * 5 15")
end

def test_aritmetic
	combine_results(
		test_plus,
		test_multiply)	
end

def test_math
	test_aritmetic
end

result  est_math
puts "resultresult}"

--------------020900010904050904010400--