From: Sander Land Date: 2006-07-02T17:55:07+09:00 Subject: Re: [QUIZ] C-Style Ints (#85) - not a spoiler, a test harness On 7/2/06, Daniel Martin wrote: > I do take issue with one of your tests, though: > ... > That just feels wrong. (except for the last one) I would write: > def test_power > ... > end Agreed, the test put way too much focus on fixnum ** fwi. This was because my implementation first assumed any binary operation was commutative (it just switched both operands if the first was a fixnum), so 2 ** uint3.new(1) was uint3.new(1)**2=1, and the test was there to help me fix this. > And maybe: > assert_equal(8, 2 ** uint3.new(67)) > ... > I really think that you want to keep exponentiation looking like > repeated multiplication of the first argument. And i really think the result should be a fwi, for consistency with multiplication ('repeated addition'). Anyway, in my implementation 2 ** uint3.new(67).to_i == 8, so there's still a way to get those calculations done as well.