Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2014-03-17 03:39:07 +0400
committerAlessandro Ranellucci <aar@cpan.org>2014-03-17 03:39:07 +0400
commit34f1511e0c61c2c9b4354dca8961d1e038c34754 (patch)
treece4bc02a886c210f86e47cb89132eb4d0392bb52 /t/custom_gcode.t
parentbc054e613c0034ec4dbf172a41e0257f71d31032 (diff)
Better fix for non-global options not being replaced in filename placeholders. Includes refactoring and a new PlaceholderParser class. Also includes regression tests. #1831
Diffstat (limited to 't/custom_gcode.t')
-rw-r--r--t/custom_gcode.t25
1 files changed, 21 insertions, 4 deletions
diff --git a/t/custom_gcode.t b/t/custom_gcode.t
index 765946f36..6e678d690 100644
--- a/t/custom_gcode.t
+++ b/t/custom_gcode.t
@@ -1,4 +1,4 @@
-use Test::More tests => 2;
+use Test::More tests => 6;
use strict;
use warnings;
@@ -44,10 +44,27 @@ use Slic3r::Test;
#==========================================================
{
- my $config = Slic3r::Config->new_from_defaults;
- is $config->replace_options('[temperature_[foo]]', { foo => '0' }),
- 200,
+ my $parser = Slic3r::GCode::PlaceholderParser->new;
+ $parser->apply_config(my $config = Slic3r::Config->new_from_defaults);
+ is $parser->process('[temperature_[foo]]', { foo => '0' }),
+ $config->temperature->[0],
"nested config options";
}
+{
+ my $config = Slic3r::Config->new_from_defaults;
+ $config->set('output_filename_format', '[travel_speed]_[layer_height].gcode');
+ $config->set('start_gcode', "TRAVEL:[travel_speed] HEIGHT:[layer_height]\n");
+ my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
+
+ my $output_file = $print->expanded_output_filepath;
+ ok $output_file !~ /\[travel_speed\]/, 'print config options are replaced in output filename';
+ ok $output_file !~ /\[layer_height\]/, 'region config options are replaced in output filename';
+
+ my $gcode = Slic3r::Test::gcode($print);
+ my ($t, $h) = map $config->$_, qw(travel_speed layer_height);
+ ok $gcode =~ /TRAVEL:$t/, 'print config options are replaced in custom G-code';
+ ok $gcode =~ /HEIGHT:$h/, 'region config options are replaced in custom G-code';
+}
+
__END__