### ----------------------------------------------------
### -- Arithmetic::PaperAndPencil
### -- Licenses: Artistic-2.0
### -- Authors: Jean Forget
### -- File: xt/12-mult-boat.rakutest
### ----------------------------------------------------
# -*- encoding: utf-8; indent-tabs-mode: nil -*-
#
# Checking the generation of HTML on two examples of multiplications.
#
# In some actions, the level has been tweaked a little to display
# intermediate results that would not have been displayed normally.
#
# Copyright 2023, 2024 Jean Forget
#
# This programme is free software; you can redistribute it and modify it under the Artistic License 2.0.

use Test;
use Arithmetic::PaperAndPencil;

plan 6;

my Str $refcsv  = 'xt/data/12-mult-boat.csv' .IO.slurp;
my Str $refhtml = 'xt/data/12-mult-boat.html'.IO.slurp;
my Arithmetic::PaperAndPencil $operation .= new;
my Arithmetic::PaperAndPencil::Number $x .= new(value => '729', radix => 10);
my Arithmetic::PaperAndPencil::Number $y .= new(value =>  '53', radix => 10);
my Arithmetic::PaperAndPencil::Number $pdt;

$pdt = $operation.multiplication(multiplicand => $x, multiplier => $y, type => 'boat');
is($pdt.value, '38637', "53 times 729 is 38637");
$pdt = $operation.multiplication(multiplicand => $x, multiplier => $y, type => 'boat', direction => 'rtl');
is($pdt.value, '38637', "53 times 729 is 38637, even if calculated right-to-left");

$x .= new(value => '628');
$y .= new(value => '234');
$pdt = $operation.multiplication(multiplicand => $x, multiplier => $y, type => 'boat', mult-and-add => 'combined');
is($pdt.value, '146952', '234 times 628 is 146952');

$x .= new(value => '345');
$y .= new(value => '333');
$pdt = $operation.multiplication(multiplicand => $x, multiplier => $y, type => 'boat', mult-and-add => 'combined', direction => 'rtl');
is($pdt.value, '114885', '333 times 345 is 114885');

is($operation.csv, $refcsv, "Checking CSV file");
my $html = $operation.html(lang => 'fr', silent => False, level => 4);
is($html, $refhtml, "Checking HTML file");

done-testing;


