21_gcode.t 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Slic3r::XS;
  5. use Test::More tests => 5;
  6. {
  7. my $gcodegen = Slic3r::GCode->new;
  8. $gcodegen->set_origin(Slic3r::Pointf->new(10,0));
  9. is_deeply $gcodegen->origin->pp, [10,0], 'set_origin';
  10. $gcodegen->origin->translate(5,5);
  11. is_deeply $gcodegen->origin->pp, [15,5], 'origin returns reference to point';
  12. }
  13. {
  14. my $config = Slic3r::Config::Static::new_FullPrintConfig;
  15. my $gcodegen = Slic3r::GCode->new;
  16. $config->set('use_firmware_retraction', 1);
  17. $config->set('gcode_flavor', "reprap");
  18. $config->set('gcode_comments', 1);
  19. $gcodegen->apply_print_config($config);
  20. $gcodegen->writer->set_extruders([0]);
  21. $gcodegen->writer->set_extruder(0);
  22. my @output = split(/\n/, $gcodegen->retract(1));
  23. is $output[0], "G10 S1 ; retract for toolchange extruder 0", 'Produces long retract for fw marlin retract';
  24. }
  25. {
  26. my $config = Slic3r::Config::Static::new_FullPrintConfig;
  27. $config->set('use_firmware_retraction', 1);
  28. $config->set('gcode_flavor', "repetier");
  29. $config->set('gcode_comments', 1);
  30. my $gcodegen = Slic3r::GCode->new;
  31. $gcodegen->apply_print_config($config);
  32. $gcodegen->writer->set_extruders([0]);
  33. $gcodegen->writer->set_extruder(0);
  34. my @output = split(/\n/, $gcodegen->retract(1));
  35. is $output[0], "G10 S1 ; retract for toolchange extruder 0", 'Produces long retract for fw repetier retract';
  36. }
  37. {
  38. my $config = Slic3r::Config::Static::new_FullPrintConfig;
  39. $config->set('gcode_flavor', "smoothie");
  40. $config->set('use_firmware_retraction', 1);
  41. $config->set('gcode_comments', 1);
  42. my $gcodegen = Slic3r::GCode->new;
  43. $gcodegen->apply_print_config($config);
  44. $gcodegen->writer->set_extruders([0]);
  45. $gcodegen->writer->set_extruder(0);
  46. my @output = split(/\n/, $gcodegen->retract(1));
  47. ok($output[0] eq "G10 ; retract for toolchange extruder 0", 'Produces regular retract for flavors that are not Marlin or Repetier');
  48. }
  49. __END__