Add int() and % (modulo)

This commit is contained in:
Matthias Urlichs 2019-12-04 09:31:21 +01:00
parent a00ff7b06f
commit 329ad97a84
2 changed files with 38 additions and 0 deletions

View file

@ -67,6 +67,8 @@ use Slic3r::Test;
is $parser->process('{2*3/6}'), '1', 'math: 2*3/6';
is $parser->process('{2*3/12}'), '0', 'math: 2*3/12';
ok abs($parser->process('{2.*3/12}') - 0.5) < 1e-7, 'math: 2.*3/12';
is $parser->process('{10%2.5}') '0', 'math: 10 % 2.5';
is $parser->process('{11/2.5-1}') '1', 'math: 11 % 2.5';
is $parser->process('{2*(3-12)}'), '-18', 'math: 2*(3-12)';
is $parser->process('{2*foo*(3-12)}'), '0', 'math: 2*foo*(3-12)';
is $parser->process('{2*bar*(3-12)}'), '-36', 'math: 2*bar*(3-12)';
@ -75,6 +77,7 @@ use Slic3r::Test;
is $parser->process('{max(12, 14)}'), '14', 'math: max(12, 14)';
is $parser->process('{min(13.4, -1238.1)}'), '-1238.1', 'math: min(13.4, -1238.1)';
is $parser->process('{max(13.4, -1238.1)}'), '13.4', 'math: max(13.4, -1238.1)';
is $parser->process('{int(13.4)}'), '13', 'math: int(13.4)';
# Test the boolean expression parser.
is $parser->evaluate_boolean_expression('12 == 12'), 1, 'boolean expression parser: 12 == 12';