aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2026-01-02 19:54:47 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2026-01-02 19:54:47 +1300
commitcb7d51d758eb44de3eee8dcc06b36e4c68857d2d (patch)
tree405e3ff462f3cc2714d6e0658e84affd2471ddd1
parent0ef8a6aabfafdfacf3798fe05bad984fb3e85e52 (diff)
Multiplication test program
-rw-r--r--test/multo.adb102
-rw-r--r--tests.gpr2
2 files changed, 104 insertions, 0 deletions
diff --git a/test/multo.adb b/test/multo.adb
new file mode 100644
index 0000000..ad49453
--- /dev/null
+++ b/test/multo.adb
@@ -0,0 +1,102 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Licensed under the Sunset License v1.0
+
+-- See license.txt for further details
+
+
+with
+
+ Ada.Text_IO,
+ Kompsos.Math,
+ Kompsos.Pretty_Print;
+
+
+procedure Multo is
+
+ package TIO renames Ada.Text_IO;
+
+
+ package InKomp is new Kompsos (Integer);
+ use InKomp;
+
+ package Math is new InKomp.Math (0, 1);
+
+ package Printer is new InKomp.Pretty_Print (Integer'Image);
+
+
+ function B
+ (Item : in Natural)
+ return Term
+ renames Math.Build;
+
+ function P
+ (Item : in Integer)
+ return String
+ renames Printer.Image;
+
+ function PV
+ (Item : in Term)
+ return String is
+ begin
+ return P (Math.Value (Item));
+ exception
+ when others =>
+ return Printer.Image (Item);
+ end PV;
+
+
+ procedure Test
+ (Multiplier, Multiplicand : in Natural)
+ is
+ Relation : Goal := Empty_Goal;
+ Product : constant Term := Relation.Fresh;
+ Result : State;
+ begin
+ Math.Multiply (Relation, B (Multiplier) & B (Multiplicand) & Product);
+ Result := Relation.Run;
+ TIO.Put_Line (P (Multiplier) & " * " & P (Multiplicand) &
+ " = " & PV (Product.Resolve (Result)));
+ end Test;
+
+begin
+
+ TIO.Put_Line ("Multiplication");
+ Test (0, 1);
+ Test (2, 0);
+ Test (1, 3);
+ Test (5, 1);
+ Test (2, 7);
+ Test (4, 4);
+ Test (3, 3);
+ Test (10, 2);
+ Test (11, 4);
+ Test (8, 7);
+ Test (3, 5);
+ Test (6, 3);
+ Test (3, 6);
+ Test (20, 2);
+ Test (3, 7);
+ Test (14, 4);
+ Test (5, 8);
+ Test (16, 7);
+ Test (5, 3);
+ Test (6, 5);
+ Test (5, 6);
+ Test (12, 3);
+ Test (3, 9);
+ Test (6, 6);
+ Test (3, 12);
+ Test (40, 2);
+ Test (3, 11);
+ Test (6, 7);
+ Test (7, 6);
+ Test (28, 4);
+ Test (3, 13);
+ Test (10, 8);
+ Test (5, 16);
+
+end Multo;
+
+
diff --git a/tests.gpr b/tests.gpr
index 34703a7..5078508 100644
--- a/tests.gpr
+++ b/tests.gpr
@@ -21,6 +21,7 @@ project Tests is
"divo.adb",
"fivesix.adb",
"membero.adb",
+ "multo.adb",
"pprint.adb",
"rembero.adb",
"trees.adb");
@@ -31,6 +32,7 @@ project Tests is
for Executable ("divo.adb") use "divo";
for Executable ("fivesix.adb") use "fivesix";
for Executable ("membero.adb") use "membero";
+ for Executable ("multo.adb") use "multo";
for Executable ("pprint.adb") use "pprint";
for Executable ("rembero.adb") use "rembero";
for Executable ("trees.adb") use "trees";