Refactor and extend t/retraction.t
This commit is contained in:
parent
3a2ca92ec3
commit
cf90033fd0
@ -1,4 +1,4 @@
|
||||
use Test::More;
|
||||
use Test::More tests => 2;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
@ -8,14 +8,11 @@ BEGIN {
|
||||
}
|
||||
|
||||
use Slic3r;
|
||||
use Slic3r::Geometry qw(epsilon);
|
||||
use Slic3r::Test;
|
||||
|
||||
{
|
||||
my $config = Slic3r::Config->new(
|
||||
retract_length => [1.5],
|
||||
retract_before_travel => [3],
|
||||
);
|
||||
my $config = Slic3r::Config->new_from_defaults;
|
||||
|
||||
my $test = sub {
|
||||
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
||||
|
||||
my $retracted = 1; # ignore the first travel move from home to first point
|
||||
@ -23,20 +20,30 @@ use Slic3r::Test;
|
||||
my ($self, $cmd, $args, $info) = @_;
|
||||
|
||||
if ($info->{retracting}) {
|
||||
ok Slic3r::Test::compare(-$info->{dist_E}, $config->retract_length->[0]),
|
||||
'retracted by the right amount';
|
||||
fail 'retracted by the correct amount'
|
||||
if !Slic3r::Test::compare(-$info->{dist_E}, $config->retract_length->[0]);
|
||||
$retracted = 1;
|
||||
}
|
||||
if ($info->{extruding}) {
|
||||
$retracted = 0;
|
||||
if ($retracted) {
|
||||
fail 'unretracted by the correct amount'
|
||||
if !Slic3r::Test::compare($info->{dist_E}, $config->retract_length->[0] + $config->retract_restart_extra->[0]);
|
||||
$retracted = 0;
|
||||
}
|
||||
}
|
||||
if ($info->{travel} && $info->{dist_XY} >= $config->retract_before_travel->[0]) {
|
||||
ok $retracted,
|
||||
'retracted before long travel move';
|
||||
fail 'retracted before long travel move' if !$retracted;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
1;
|
||||
};
|
||||
|
||||
done_testing;
|
||||
$config->set('retract_length', [1.5]);
|
||||
$config->set('retract_before_travel', [3]);
|
||||
ok $test->(), 'retraction';
|
||||
|
||||
$config->set('retract_restart_extra', [1]);
|
||||
ok $test->(), 'retraction with restart extra length';
|
||||
|
||||
__END__
|
||||
|
Loading…
Reference in New Issue
Block a user