### ----------------------------------------------------
### -- Arithmetic::PaperAndPencil
### -- Licenses: Artistic-2.0
### -- Authors: Jean Forget
### -- File: t/07-mult.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 8;

my Str $refcsv  = 't/data/07-mult.csv'.IO.slurp;
my Str $refhtml = 't/data/07-mult.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 =>   '3', radix => 10);
my Arithmetic::PaperAndPencil::Number $z .= new(value => '123', radix => 10);
my Arithmetic::PaperAndPencil::Number $pdt;

$pdt = $operation.multiplication(multiplicand => $x, multiplier => $y, type => 'std'       ); is($pdt.value, '2187');
$pdt = $operation.multiplication(multiplicand => $y, multiplier => $x, type => 'std'       ); is($pdt.value, '2187');
$pdt = $operation.multiplication(multiplicand => $x, multiplier => $y, type => 'jalousie-A'); is($pdt.value, '2187');
$pdt = $operation.multiplication(multiplicand => $x, multiplier => $y, type => 'jalousie-B'); is($pdt.value, '2187');
$pdt = $operation.multiplication(multiplicand => $x, multiplier => $z, :type<jalousie-A>, :product<straight>); is($pdt.value, '89667');
$pdt = $operation.multiplication(multiplicand => $x, multiplier => $z, :type<jalousie-B>, :product<straight>); is($pdt.value, '89667');

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

done-testing;


