#!perl use v5.14; use warnings; use Test::More tests => 2; my $val = "2.123450"; is( $val, 2.123450 ); cmp_ok( $val, '==', 2.123450 );
This results in:
1..2 not ok 1 # Failed test at tmp/bad_is.pl line 9. # got: '2.123450' # expected: '2.12345' ok 2 # Looks like you failed 1 test of 2.
The issue is fairly obvious when it’s laid out like this:
is() does a string comparison, which means that trailing zero matters. One day, though, I promise you, you’ll hit a problem like this and will spend hours debugging it, only to smack your forehead when you finally see it. You can prevent that by explicitly giving a comparison operator to