What steps will reproduce the problem?
1. Define a greatest common divisor function as follows
def gcd(a,b){
if: (a == b) then: {a;} else: {
if: (a > b) then: {gcd(a - b,b)} else: {gcd(a,b - a)};
};
}
2. Run gcd(3,648), gcd(3,649) or gcd(648,3). Probably there are a number of
other possibilities
to cause the error, but for most pairs of values the function works (eg
gcd(4,648) is fine). This
was done in the UnitTest framework as follows
def sessionModule := object:{
def sessionTest(){
extend: /.at.unit.test.UnitTest.new("Session1Test") with: {
def testGcd() {
self.assertEquals(1, gcd(647,3));
};
};
};
};
Using a mac I get the following error:
Starting unit test Session1Test(4 tests)
Error in test testGcd: <exception:<type tag:ReflectionFailure>: Native method
base:if:then:else:
threw internal exception caused by null>
Native method base:if:then:else: threw internal exception caused by null
origin:
at if:then:else:(a.==(b), { a }, { if:then:else:(a.>(b), { gcd(a.-(b), b) }, {
gcd(a, b.-(a)) }) })
at gcd(a.-(b), b)
at if:then:else:(a.>(b), { gcd(a.-(b), b) }, { gcd(a, b.-(a)) })
at if:then:else:(a.==(b), { a }, { if:then:else:(a.>(b), { gcd(a.-(b), b) }, {
gcd(a, b.-(a)) }) })
at gcd(a.-(b), b)
at if:then:else:(a.>(b), { gcd(a.-(b), b) }, { gcd(a, b.-(a)) })
at if:then:else:(a.==(b), { a }, { if:then:else:(a.>(b), { gcd(a.-(b), b) }, {
gcd(a, b.-(a)) }) })
at gcd(a.-(b), b)
at if:then:else:(a.>(b), { gcd(a.-(b), b) }, { gcd(a, b.-(a)) })
at if:then:else:(a.==(b), { a }, { if:then:else:(a.>(b), { gcd(a.-(b), b) }, {
gcd(a, b.-(a)) }) })
at gcd(a.-(b), b)
at if:then:else:(a.>(b), { gcd(a.-(b), b) }, { gcd(a, b.-(a)) })
at if:then:else:(a.==(b), { a }, { if:then:else:(a.>(b), { gcd(a.-(b), b) }, {
gcd(a, b.-(a)) }) })
at gcd(a.-(b), b)
...
at testMethod(1)
at sessionModule.sessionTest.runTest()
Original issue reported on code.google.com by ellie.dh...@gmail.com on 19 Mar 2009 at 1:35
Original issue reported on code.google.com by
ellie.dh...@gmail.com
on 19 Mar 2009 at 1:35