2015-01-05 19:07:47 +00:00
|
|
|
use Test::More tests => 1;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
|
|
|
}
|
|
|
|
|
|
|
|
use List::Util qw();
|
|
|
|
use Slic3r;
|
2015-01-05 23:35:39 +00:00
|
|
|
use Slic3r::Geometry qw(epsilon);
|
2015-01-05 19:07:47 +00:00
|
|
|
use Slic3r::Test;
|
|
|
|
|
|
|
|
{
|
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
|
|
|
$config->set('pressure_advance', 10);
|
|
|
|
$config->set('retract_length', [1]);
|
|
|
|
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2);
|
2015-01-05 23:35:39 +00:00
|
|
|
my $retracted = $config->retract_length->[0];
|
2015-01-05 19:07:47 +00:00
|
|
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
|
2015-01-05 23:35:39 +00:00
|
|
|
if ($info->{extruding} && !$info->{dist_XY}) {
|
|
|
|
$retracted += $info->{dist_E};
|
2015-01-05 19:07:47 +00:00
|
|
|
} elsif ($info->{retracting}) {
|
2015-01-05 23:35:39 +00:00
|
|
|
$retracted += $info->{dist_E};
|
2015-01-05 19:07:47 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-01-05 23:35:39 +00:00
|
|
|
ok abs($retracted) < epsilon, 'all retractions are compensated';
|
2015-01-05 19:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__END__
|