pressure.t 944 B

12345678910111213141516171819202122232425262728293031323334353637
  1. use Test::More tests => 1;
  2. use strict;
  3. use warnings;
  4. BEGIN {
  5. use FindBin;
  6. use lib "$FindBin::Bin/../lib";
  7. use local::lib "$FindBin::Bin/../local-lib";
  8. }
  9. use List::Util qw();
  10. use Slic3r;
  11. use Slic3r::Geometry qw(epsilon);
  12. use Slic3r::Test;
  13. {
  14. my $config = Slic3r::Config->new_from_defaults;
  15. $config->set('pressure_advance', 10);
  16. $config->set('retract_length', [1]);
  17. my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2);
  18. my $retracted = $config->retract_length->[0];
  19. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  20. my ($self, $cmd, $args, $info) = @_;
  21. if ($info->{extruding} && !$info->{dist_XY}) {
  22. $retracted += $info->{dist_E};
  23. } elsif ($info->{retracting}) {
  24. $retracted += $info->{dist_E};
  25. }
  26. });
  27. ok abs($retracted) < 0.01, 'all retractions are compensated';
  28. }
  29. __END__