The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

use strict;
BEGIN { plan tests => 4 }
my $m = new Math::Expression::Evaluator;
ok($m, "new works");
sub exec_fail {
my ($string, $hash, $explanation) = @_;
$m->parse($string);
eval { $m->val($hash) };
ok($@, $explanation);
}
exec_fail 'a', {}, 'undefined variable 1';
exec_fail 'a', {b => 1}, 'undefined variable 2';
exec_fail 'foo()', {}, 'undefined function';