Bugfix: crash when extending an array option by 2+ positions. #1908
This commit is contained in:
parent
f6e99f1467
commit
c3bb8a69db
4 changed files with 64 additions and 33 deletions
|
@ -4,7 +4,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 100;
|
||||
use Test::More tests => 110;
|
||||
|
||||
foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
|
||||
$config->set('layer_height', 0.3);
|
||||
|
@ -62,6 +62,11 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
|
|||
is $config->serialize('extruder_offset'), '10x20,30x45', 'serialize points';
|
||||
$config->set_deserialize('extruder_offset', '20x10');
|
||||
is_deeply $config->get('extruder_offset'), [[20,10]], 'deserialize points';
|
||||
{
|
||||
my @values = ([10,20]);
|
||||
$values[2] = [10,20]; # implicitely extend array; this is not the same as explicitely assigning undef to second item
|
||||
ok !$config->set('extruder_offset', \@values), 'reject undef points';
|
||||
}
|
||||
|
||||
# truncate ->get() to first decimal digit
|
||||
$config->set('nozzle_diameter', [0.2,3]);
|
||||
|
@ -71,12 +76,22 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
|
|||
is_deeply [ map int($_*10)/10, @{$config->get('nozzle_diameter')} ], [0.1,0.4], 'deserialize floats';
|
||||
$config->set_deserialize('nozzle_diameter', '3');
|
||||
is_deeply [ map int($_*10)/10, @{$config->get('nozzle_diameter')} ], [3], 'deserialize a single float';
|
||||
{
|
||||
my @values = (0.4);
|
||||
$values[2] = 2; # implicitely extend array; this is not the same as explicitely assigning undef to second item
|
||||
ok !$config->set('nozzle_diameter', \@values), 'reject undef floats';
|
||||
}
|
||||
|
||||
$config->set('temperature', [180,210]);
|
||||
is_deeply $config->get('temperature'), [180,210], 'set/get ints';
|
||||
is $config->serialize('temperature'), '180,210', 'serialize ints';
|
||||
$config->set_deserialize('temperature', '195,220');
|
||||
is_deeply $config->get('temperature'), [195,220], 'deserialize ints';
|
||||
{
|
||||
my @values = (180);
|
||||
$values[2] = 200; # implicitely extend array; this is not the same as explicitely assigning undef to second item
|
||||
ok !$config->set('temperature', \@values), 'reject undef ints';
|
||||
}
|
||||
|
||||
$config->set('wipe', [1,0]);
|
||||
is_deeply $config->get('wipe'), [1,0], 'set/get bools';
|
||||
|
@ -86,12 +101,22 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
|
|||
is $config->serialize('wipe'), '1,0', 'serialize bools';
|
||||
$config->set_deserialize('wipe', '0,1,1');
|
||||
is_deeply $config->get('wipe'), [0,1,1], 'deserialize bools';
|
||||
{
|
||||
my @values = (1);
|
||||
$values[2] = 1; # implicitely extend array; this is not the same as explicitely assigning undef to second item
|
||||
ok !$config->set('wipe', \@values), 'reject undef bools';
|
||||
}
|
||||
|
||||
$config->set('post_process', ['foo','bar']);
|
||||
is_deeply $config->get('post_process'), ['foo','bar'], 'set/get strings';
|
||||
is $config->serialize('post_process'), 'foo;bar', 'serialize strings';
|
||||
$config->set_deserialize('post_process', 'bar;baz');
|
||||
is_deeply $config->get('post_process'), ['bar','baz'], 'deserialize strings';
|
||||
{
|
||||
my @values = ('foo');
|
||||
$values[2] = 'bar'; # implicitely extend array; this is not the same as explicitely assigning undef to second item
|
||||
ok !$config->set('post_process', \@values), 'reject undef strings';
|
||||
}
|
||||
|
||||
is_deeply [ sort @{$config->get_keys} ], [ sort keys %{$config->as_hash} ], 'get_keys and as_hash';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue