Skip to content

Commit c58990e

Browse files
committed
Fix the unit test that attempts to construct a NumberWithUnits with no number.
1 parent 3982803 commit c58990e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/Parser/Legacy/NumberWithUnits.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ sub makeValue {
363363
my $value = shift;
364364
my %options = (context => $self->context, @_);
365365
my $num = Value::makeValue($value, %options);
366-
return bless $num, 'Parser::Legacy::FormulaWithUnits' if $num->classMatch('Formula');
366+
return bless $num, 'Parser::Legacy::FormulaWithUnits' if defined $num && $num->classMatch('Formula');
367367
Value::Error("A number with units must be a constant, not %s", lc(Value::showClass($num)))
368368
unless Value::isReal($num);
369369
bless $num, $options{class};

t/units/basic_parser.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ subtest 'Test error handling' => sub {
9898
like(dies { NumberWithUnits(1) }, qr/You must provide units for your number/, 'No unit given');
9999
like(
100100
dies { NumberWithUnits('J') },
101-
qr/You must provide units for your number/,
101+
qr/A number with units must be a constant, not ''/,
102102
'No value given, wants 2 arguments'
103103
);
104104
};

0 commit comments

Comments
 (0)