Skip to content

Commit

Permalink
Bugfix: [layer_num] was out of order because of support material laye…
Browse files Browse the repository at this point in the history
…rs having their order numbers. Now we use a unique continuous series. Includes regression test. #2634
  • Loading branch information
alranel committed May 3, 2015
1 parent 73e32df commit 63af442
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion t/custom_gcode.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Test::More tests => 13;
use Test::More tests => 15;
use strict;
use warnings;

Expand All @@ -7,6 +7,7 @@ BEGIN {
use lib "$FindBin::Bin/../lib";
}

use List::Util qw(first);
use Slic3r;
use Slic3r::Test;

Expand Down Expand Up @@ -104,4 +105,29 @@ use Slic3r::Test;
}
}

{
my $config = Slic3r::Config->new_from_defaults;
$config->set('before_layer_gcode', ';BEFORE [layer_num]');
$config->set('layer_gcode', ';CHANGE [layer_num]');
$config->set('support_material', 1);
$config->set('layer_height', 0.2);
my $print = Slic3r::Test::init_print('overhang', config => $config);
my $gcode = Slic3r::Test::gcode($print);

my @before = ();
my @change = ();
foreach my $line (split /\R+/, $gcode) {
if ($line =~ /;BEFORE (\d+)/) {
push @before, $1;
} elsif ($line =~ /;CHANGE (\d+)/) {
push @change, $1;
fail 'inconsistent layer_num before and after layer change'
if $1 != $before[-1];
}
}
is_deeply \@before, \@change, 'layer_num is consistent before and after layer changes';
ok !defined(first { $change[$_] != $change[$_-1]+1 } 1..$#change),
'layer_num grows continously'; # i.e. no duplicates or regressions
}

__END__

0 comments on commit 63af442

Please sign in to comment.