使用元运算符进行测试不会打印测试描述
Testing with a metaoperator doesn't print the test description
我在复杂数组上编写测试,并且在使用 Z≅
运算符检查数组是否大致相等时,发现缺少测试描述。
我试图对这段代码进行打高尔夫球,以找出显示我所看到的结果的最简单的情况。即使我使用 Num 或 Int 变量和 Z==
运算符,第二次测试中也缺少描述。
use Test;
my @a = 1e0, 3e0;
my @b = 1e0, 3e0;
ok @a[0] == @b[0], 'description1'; # prints: ok 1 - description1
ok @a[^2] Z== @b[^2], 'description2'; # prints: ok 2 -
done-testing;
是否有简单的解释或者这是一个错误?
这只是优先级 -- 您需要括号。
==
是一个二元运算,它在两边接受 一个操作数 。
Z
metaop 将其运算符分发到两侧的列表。
use Test;
my @a = 1e0, 3e0;
my @b = 1e0, 3e0;
ok @a[0] == @b[0], 'description1'; # prints: ok 1 - description1
ok (@a[^2] Z== @b[^2]), 'description2'; # prints: ok 2 - description2
done-testing;
没有括号,'description2'
成为右侧列表的附加元素。根据 the doc for Z
:
If one of the operands runs out of elements prematurely, the zip operator will stop.
我在复杂数组上编写测试,并且在使用 Z≅
运算符检查数组是否大致相等时,发现缺少测试描述。
我试图对这段代码进行打高尔夫球,以找出显示我所看到的结果的最简单的情况。即使我使用 Num 或 Int 变量和 Z==
运算符,第二次测试中也缺少描述。
use Test;
my @a = 1e0, 3e0;
my @b = 1e0, 3e0;
ok @a[0] == @b[0], 'description1'; # prints: ok 1 - description1
ok @a[^2] Z== @b[^2], 'description2'; # prints: ok 2 -
done-testing;
是否有简单的解释或者这是一个错误?
这只是优先级 -- 您需要括号。
==
是一个二元运算,它在两边接受 一个操作数 。
Z
metaop 将其运算符分发到两侧的列表。
use Test;
my @a = 1e0, 3e0;
my @b = 1e0, 3e0;
ok @a[0] == @b[0], 'description1'; # prints: ok 1 - description1
ok (@a[^2] Z== @b[^2]), 'description2'; # prints: ok 2 - description2
done-testing;
没有括号,'description2'
成为右侧列表的附加元素。根据 the doc for Z
:
If one of the operands runs out of elements prematurely, the zip operator will stop.