在使用is_deeply()函数时,如果需要对其结果进行否定(即测试结果应该为假),可以使用not()函数或!运算符来实现。
示例代码:
使用not()函数:
use Test::More;
my $hash1 = { a => 1, b => 2 };
my $hash2 = { b => 2, a => 1 };
# 测试 $hash1 和 $hash2 不相等
ok( not is_deeply($hash1, $hash2), 'hashes are not equal' );
done_testing();
使用!运算符:
use Test::More;
my $hash1 = { a => 1, b => 2 };
my $hash2 = { b => 2, a => 1 };
# 测试 $hash1 和 $hash2 不相等
ok( ! is_deeply($hash1, $hash2), 'hashes are not equal' );
done_testing();
在这两个示例中,使用not()函数和!运算符都达到了对is_deeply()函数测试结果进行否定的效果。