本文整理汇总了TypeScript中fast-check.anything函数的典型用法代码示例。如果您正苦于以下问题:TypeScript anything函数的具体用法?TypeScript anything怎么用?TypeScript anything使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了anything函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should be symmetric', () => {
const safeExpectEqual = (a, b) => {
try {
expect(a).toEqual(b);
return true;
} catch (err) {
return false;
}
};
fc.assert(
fc.property(
fc.anything(anythingSettings),
fc.anything(anythingSettings),
(a, b) => {
// Given: a and b values
// Assert: We expect `expect(a).toEqual(b)`
// to be equivalent to `expect(b).toEqual(a)`
expect(safeExpectEqual(a, b)).toBe(safeExpectEqual(b, a));
},
),
{
...assertSettings,
examples: [
[0, 5e-324], // Issue #7941
// [
// new Set([false, true]),
// new Set([new Boolean(true), new Boolean(true)]),
// ], // Issue #7975
],
},
);
});
示例2: it
it('should always find the value when inside the array', () => {
fc.assert(
fc.property(
fc.array(fc.anything(anythingSettings)),
fc.array(fc.anything(anythingSettings)),
fc.anything(anythingSettings).filter(v => !Number.isNaN(v)),
(startValues, endValues, v) => {
// Given: startValues, endValues arrays and v value (not NaN)
expect([...startValues, v, ...endValues]).toContain(v);
},
),
assertSettings,
);
});
示例3: it
it('should always find the value when inside the array', () => {
fc.assert(
fc.property(
fc.array(fc.anything(anythingSettings)),
fc.array(fc.anything(anythingSettings)),
fc.anything(anythingSettings),
(startValues, endValues, v) => {
// Given: startValues, endValues arrays and v any value
expect([...startValues, v, ...endValues]).toContainEqual(v);
},
),
assertSettings,
);
});
示例4: it
it("should produce string evaluating to the original value", () => {
fc.assert(
fc.property(fc.anything(), value => {
expect(evalValue(stringify(value))).toEqual(value);
})
);
});
示例5: it
it('should be reflexive', () => {
fc.assert(
fc.property(fc.dedup(fc.anything(anythingSettings), 2), ([a, b]) => {
// Given: a and b identical values
expect(a).toStrictEqual(b);
}),
assertSettings,
);
});