[Home]
[
prev
] [
up
] [
next
] ((test/myalps/binpow.as))
13
TestMyBinaryPowering
89
⟨
*
13
⟩
+
≡
⊲
82
-------------------------------------------------------------------
----
----
ALLPROSE
----
Copyright
(C)
Ralf
Hemmecke
(ralf@hemmecke.de)
----
http://www.hemmecke.de/aldor
----
-------------------------------------------------------------------
#assert
DontNeedLibraryTestCases
#include
"testcases"
TestMyBinaryPowering
:
TestCaseType
with
{
#include
"binpow.signatures.as"
}
==
add
{
macro
{
Z
==
Integer;
I
==
MachineInteger;
assertEq(v,
e,
r)
==
assertEquals(r,
binaryPower(1,
v,
e));
binaryPowerTest1(Z,
I,
TIMES)
==
{
import
from
Z,
I;
import
from
MyBinaryPowering
(Z,
TIMES,
I);
assertEq(3,
0,
1);
assertEq(3,
1,
3);
assertEq(3,
2,
9);
assertEq(3,
3,
27);
assertEq(3,
4,
81);
assertEq(3,
5,
243);
}
binaryMultiplicationTest1(Z,
I,
PLUS)
==
{
import
from
Z,
I;
import
from
MyBinaryPowering
(Z,
PLUS,
I);
assertEq(3,
0,
1);
assertEq(3,
1,
4);
assertEq(3,
2,
7);
assertEq(3,
3,
10);
assertEq(3,
4,
13);
assertEq(3,
5,
16);
}
}
import
from
TestCaseTools;
testBinaryPower1():
()
==
binaryPowerTest1(Z,
I,
*$Z);
testBinaryPower2():
()
==
binaryPowerTest1(I,
Z,
*$I);
testBinaryPower3():
()
==
binaryPowerTest1(Z,
I,
times!$Z);
testBinaryPower4():
()
==
binaryPowerTest1(I,
Z,
times!$I);
testBinaryMult1():
()
==
binaryMultiplicationTest1(Z,
I,
+$Z);
testBinaryMult2():
()
==
binaryMultiplicationTest1(I,
Z,
+$I);
testBinaryMult3():
()
==
binaryMultiplicationTest1(Z,
I,
add!$Z);
testBinaryMult4():
()
==
binaryMultiplicationTest1(I,
Z,
add!$I);
testBinaryPowerUsage():
()
==
{
import
from
I,
Z,
MyBinaryPowering
(Z,
*$Z,
I);
assertEquals(Z,
167121978496,
binaryPower(67,
22,
7));
}
testBinaryMultUsage():
()
==
{
import
from
I,
Z,
MyBinaryPowering
(I,
+$I,
I);
assertEquals(I,
221,
binaryPower(67,
22,
7));
}
}
Defines:
TestMyBinaryPowering
, never used.
Uses
MyBinaryPowering
84
.
[Home]
[
prev
] [
up
] [
next
] ((test/myalps/binpow.as))