cli/mpfr_expr_cli API
cli/mpfr_expr_cli 是 MPFR 参考数据的命令行运行器。它读取一个文件,检测其格式,用 frontend/mpfr_expr 解析并执行,然后打印摘要。通常以 floating-conformance --backend mpfr … 的方式调用它。参见教程和设计页面。
run
run(arguments) 执行一次调用并返回退出码。
pub fn run(Array[String]) -> Int
arguments[0] 是程序名,会被忽略。该运行器接受 --json 和恰好一个路径;其他任何参数(包括本运行器禁用的分片选项)都会打印 usage: mpfr-expr [--json] <MPFR sqrt, pow, or elementary corpus>。
格式根据文件内容选择:
| 内容包含 | 格式 | 解析器与执行器 | JSON corpus |
|---|---|---|---|
mpfr-elementary-v1 | 初等函数矩阵 | parse_elementary_data, execute_elementary_data | mpfr-4.2.2-elementary |
input_coefficient_hex(且不满足上一条) | 整数幂 | parse_pow_data, execute_pow_data | mpfr-4.2.2-pow-si |
| 两者都不包含 | 平方根 data_check | parse_sqrt_data, execute_sqrt_data | mpfr-4.2.2-sqrt |
出现解析错误时,第一条诊断以 source:line:1: message 的形式打印。文本输出打印一个标题、cases、passed cases、failed cases,并为每个失败输出一行 failed ID: MESSAGE。JSON 输出包含键 corpus、totalCases、passedCases、failedCases 和 failedIds。
返回值:用法、文件或解析错误时为 2;有行失败时为 1;否则为 0。
///|
test "mpfr runner usage errors" {
inspect(@mpfr_expr_cli.run(["mpfr"]), content="2")
inspect(@mpfr_expr_cli.run(["mpfr", "--shard-count=2", "data.txt"]), content="2")
}
完整公共接口
// Generated using `moon info`, DON'T EDIT IT
package "Luna-Flow/floating/cli/mpfr_expr_cli"
// Values
pub fn run(Array[String]) -> Int
// Errors
// Types and methods
// Type aliases
// Traits