diff options
| author | Jedidiah Barber <contact@jedbarber.id.au> | 2026-01-04 18:16:02 +1300 |
|---|---|---|
| committer | Jedidiah Barber <contact@jedbarber.id.au> | 2026-01-04 18:16:02 +1300 |
| commit | d9a59f478a9ebb6135a2c9bbe2e6e1b946bfbaa4 (patch) | |
| tree | 8a59d4bcb171307da6362e3544baef868320c013 /test/logo.adb | |
| parent | 6e6ae02efca7b97ff0b58790ddf05209b63a04d4 (diff) | |
Logarithm test program, base=3 not working
Diffstat (limited to 'test/logo.adb')
| -rw-r--r-- | test/logo.adb | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/test/logo.adb b/test/logo.adb new file mode 100644 index 0000000..3c2412f --- /dev/null +++ b/test/logo.adb @@ -0,0 +1,87 @@ + + +-- 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 Logo 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 + (Power, Base : in Natural) + is + Relation : Goal := Empty_Goal; + Exponent : constant Term := Relation.Fresh; + Remainder : constant Term := Relation.Fresh; + Result : State; + begin + Math.Logarithm (Relation, B (Power) & B (Base) & Exponent & Remainder); + Result := Relation.Run; + TIO.Put_Line ("log_" & P (Base) & " (" & P (Power) & ") = " & + PV (Exponent.Resolve (Result)) & " r " & PV (Remainder.Resolve (Result))); + end Test; + +begin + + TIO.Put_Line ("Logarithm"); + Test (1, 1); + Test (68, 2); + Test (68, 3); + Test (68, 4); + Test (68, 5); + Test (68, 6); + Test (68, 7); + Test (68, 8); + + TIO.New_Line; + + TIO.Put_Line ("Expected Failure"); + -- Here there is no reasonable way to assign a value to the exponent variable term + Test (68, 1); -- 1^x is always 1 so will never be 68 + -- In this case the log function is undefined for x=0 + Test (68, 0); -- 0^x is always 0 or undefined so could never be 68 + Test (0, 0); + +end Logo; + + |
