普贤教程 › 包参考
quickcheck 包
属性测试
| 项 | 值 |
|---|---|
| 包名 | quickcheck |
| 版本 | 0.2.0 |
| 可用版本 | 0.1.0 / 0.2.0 |
| 入口 | quickcheck.px |
| 分类 | 可观测与测试 |
| 文件数 / 行数 | 1 / 77 |
安装与引入
bash
pxpkg init # 首次 pxpkg add quickcheck@0.2.0 pxpkg install
px
import quickcheck所属分类教程:可观测与测试
公开接口
| 函数 | 参数 |
|---|---|
qc_forall | gen, prop, n |
qc_int | lo, hi |
qc_list | gen, maxlen |
qc_str | maxlen |
其余 4 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
qc_check | prop, n=100 |
qc_for_int | lo, hi, prop, n=100 |
qc_for_str | maxlen, prop, n=100 |
qc_bool | |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/quickcheck —— 属性测试 ------------------------------------------------------------ 纯函数库(无 IO、无状态;随机源 = 原生 random()),编译/解释双模式一致。 qc_forall(gen, prop, n) → Ok(n) | Err 随机跑 n 次;prop 为 false 即反例 Err qc_int(lo, hi) → fn() → int 随机整数生成器 qc_list(gen, maxlen) → fn() → list 随机长度列表生成器 qc_str(maxlen) → fn() → str 随机小写字母串 ============================================================