-- This is a test of the BigNum abstract data type.

with Ada.Text_IO; use Ada.Text_IO;
with BigNumPkg; use BigNumPkg;
procedure BigNumTest is
    First, Second : BigNum;
    Count : BigNum := Zero;
    Factorial : BigNum := One;
begin
    Put("Zero = ");
    Put(Zero);
    New_Line;

    Put("One = ");
    Put(One);
    New_Line;

    Put_Line("Enter 1234567890:");
    Get(First);
    Put_Line("Read in the first BigNum:");
    Put(First, Width => 15);
    New_Line;
    Put_Line("^^^^^ These should be spaces.");
    New_Line;

    Put_Line("Enter 40:");
    Get(Second);
    Put_Line("Read in the second BigNum:");
    Put(Second, Width => 15);
    New_Line;
    Put_Line("^^^^^^^^^^^^^ These should be spaces.");
    New_Line;

    Put_Line("The sum should be");
    Put_Line("1234567930:");
    Put(First + Second);
    New_Line(2);

    Put_Line("The product should be");
    Put_Line("49382715600:");
    Put(First * Second);
    New_Line(2);

    Put_Line("The factorial of the second number should be");
    Put_Line("815915283247897734345611269596115894272000000000:");
    while Count /= Second loop
        Count := Count + One;
        Factorial := Factorial * Count;
    end loop;
    Put(Factorial);
    New_Line(2);

    Put("First should be > Second: ");
    if First > Second then
        Put_Line("Yes");
    else
        Put_Line("OH NO!");
    end if;

    Put_Line("The following should eventually raise BigNumOverFlow:");
    loop
        First := First * Second;
        Put(First);
        New_Line;
    end loop;
end BigNumTest;