custom_gcode.t 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. use Test::More tests => 2;
  2. use strict;
  3. use warnings;
  4. BEGIN {
  5. use FindBin;
  6. use lib "$FindBin::Bin/../lib";
  7. }
  8. use Slic3r;
  9. use Slic3r::Test;
  10. {
  11. my $config = Slic3r::Config->new_from_defaults;
  12. my $test = sub {
  13. my ($conf) = @_;
  14. $conf ||= $config;
  15. my $print = Slic3r::Test::init_print('2x20x10', config => $conf);
  16. my $last_move_was_z_change = 0;
  17. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  18. my ($self, $cmd, $args, $info) = @_;
  19. if ($last_move_was_z_change && $cmd ne $config->layer_gcode) {
  20. fail 'custom layer G-code was not applied after Z change';
  21. }
  22. if (!$last_move_was_z_change && $cmd eq $config->layer_gcode) {
  23. fail 'custom layer G-code was not applied after Z change';
  24. }
  25. $last_move_was_z_change = (defined $info->{dist_Z} && $info->{dist_Z} > 0);
  26. });
  27. 1;
  28. };
  29. $config->set('start_gcode', '_MY_CUSTOM_START_GCODE_'); # to avoid dealing with the nozzle lift in start G-code
  30. $config->set('layer_gcode', '_MY_CUSTOM_LAYER_GCODE_');
  31. ok $test->(), "custom layer G-code is applied after Z move and before other moves";
  32. }
  33. #==========================================================
  34. {
  35. my $config = Slic3r::Config->new_from_defaults;
  36. is $config->replace_options('[temperature_[foo]]', { foo => '0' }),
  37. 200,
  38. "nested config options";
  39. }
  40. __END__