diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2012-12-23 18:56:13 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2012-12-23 18:56:13 +0400 |
commit | db754dca4d8fb2811b5c89e0a6a6e485a1aca019 (patch) | |
tree | cd8de8303f77b3a863173b617da6edcc854186d4 /t/custom_gcode.t | |
parent | 15f07197d8bbdabdad3b1d57907983ffc7108252 (diff) |
Add unit test to check that nested config options work
Diffstat (limited to 't/custom_gcode.t')
-rw-r--r-- | t/custom_gcode.t | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/t/custom_gcode.t b/t/custom_gcode.t index ea36c0cf1..69ab8fac8 100644 --- a/t/custom_gcode.t +++ b/t/custom_gcode.t @@ -1,4 +1,4 @@ -use Test::More tests => 1; +use Test::More tests => 2; use strict; use warnings; @@ -10,32 +10,43 @@ BEGIN { use Slic3r; use Slic3r::Test; -my $config = Slic3r::Config->new_from_defaults; - -my $test = sub { - my ($conf) = @_; - $conf ||= $config; - - my $print = Slic3r::Test::init_print('2x20x10', config => $conf); +{ + my $config = Slic3r::Config->new_from_defaults; - my $last_move_was_z_change = 0; - Slic3r::Test::GCodeReader->new(gcode => Slic3r::Test::gcode($print))->parse(sub { - my ($self, $cmd, $args, $info) = @_; + my $test = sub { + my ($conf) = @_; + $conf ||= $config; + + my $print = Slic3r::Test::init_print('2x20x10', config => $conf); - if ($last_move_was_z_change && $cmd ne $config->layer_gcode) { - fail 'custom layer G-code was not applied after Z change'; - } - if (!$last_move_was_z_change && $cmd eq $config->layer_gcode) { - fail 'custom layer G-code was not applied after Z change'; - } + my $last_move_was_z_change = 0; + Slic3r::Test::GCodeReader->new(gcode => Slic3r::Test::gcode($print))->parse(sub { + my ($self, $cmd, $args, $info) = @_; + + if ($last_move_was_z_change && $cmd ne $config->layer_gcode) { + fail 'custom layer G-code was not applied after Z change'; + } + if (!$last_move_was_z_change && $cmd eq $config->layer_gcode) { + fail 'custom layer G-code was not applied after Z change'; + } + + $last_move_was_z_change = (defined $info->{dist_Z} && $info->{dist_Z} > 0); + }); - $last_move_was_z_change = (defined $info->{dist_Z} && $info->{dist_Z} > 0); - }); + 1; + }; - 1; -}; + $config->set('layer_gcode', '_MY_CUSTOM_GCODE_'); + ok $test->(), "custom layer G-code is applied after Z move and before other moves"; +} + +#========================================================== -$config->set('layer_gcode', '_MY_CUSTOM_GCODE_'); -ok $test->(), "custom layer G-code is applied after Z move and before other moves"; +{ + my $config = Slic3r::Config->new_from_defaults; + is $config->replace_options('[temperature_[foo]]', { foo => '0' }), + 200, + "nested config options"; +} __END__ |