test(p4): prove row-store/columnar table equivalence
- Add semantic fixture 72: a .mq.md columnar List/Map table store, converted, sorted and filtered; compare headers/cells with the T0 row Table via a cell-wise helper (Table == is not structural in this language version). - Teach the direct-runtime semantic harness to resolve entry std: imports. - Update ADR-0032, P4 status, docs/changelog/evidence; semantic goldens 72. Gate: fmt, clippy -D warnings, 430 tests passed.
This commit is contained in:
1 parent
e981168d92
commit
b020904199
9 files changed
+359
-5
No files matched your search
+1
-1
@@ -15,7 +15,7 @@ no test commits, copies or rewrites files outside a throw-away temp directory.
|
||||
tests/
|
||||
├── conformance/
|
||||
│ ├── ast/ 160 × *.mq.md + sibling *.ast.json goldens
|
||||
│ └── semantics/ 71 × *.mq.md + sibling *.expected.json goldens
|
||||
│ └── semantics/ 72 × *.mq.md + sibling *.expected.json goldens
|
||||
├── negative/
|
||||
│ ├── *.mq.md 52 × compile-time hard-error fixtures + *.expected.json
|
||||
│ ├── warnings/ 6 × inert-executable warning fixtures + *.expected.json
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"items": [
|
||||
{
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "bool",
|
||||
"value": true
|
||||
}
|
||||
],
|
||||
"type": "list"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
---
|
||||
import:
|
||||
数据表: "std:data/table"
|
||||
---
|
||||
|
||||
## 转表
|
||||
|
||||
`(列存)`
|
||||
|
||||
**列 = 列存["列"]**
|
||||
|
||||
**数据 = 列存["数据"]**
|
||||
|
||||
**行数 = 0**
|
||||
|
||||
1. `长度(数据) > 0`
|
||||
|
||||
**行数 = 长度(数据[0])**
|
||||
|
||||
2. `true`
|
||||
|
||||
**忽略 = 0**
|
||||
|
||||
**行列表 = []**
|
||||
|
||||
**行号 = 0**
|
||||
|
||||
- `行号 < 行数`
|
||||
|
||||
**行 = []**
|
||||
|
||||
**列号 = 0**
|
||||
|
||||
- `列号 < 长度(列)`
|
||||
|
||||
**行 = list.append(行, 数据[列号][行号])**
|
||||
|
||||
**列号 = 列号 + 1**
|
||||
|
||||
**行列表 = list.append(行列表, 行)**
|
||||
|
||||
**行号 = 行号 + 1**
|
||||
|
||||
*表(列, 行列表)*
|
||||
|
||||
## 列存排序
|
||||
|
||||
`(列存, 目标列)`
|
||||
|
||||
**列 = 列存["列"]**
|
||||
|
||||
**数据 = 列存["数据"]**
|
||||
|
||||
**行数 = 长度(数据[目标列])**
|
||||
|
||||
**顺序 = []**
|
||||
|
||||
**行号 = 0**
|
||||
|
||||
- `行号 < 行数`
|
||||
|
||||
**顺序 = list.append(顺序, 行号)**
|
||||
|
||||
**行号 = 行号 + 1**
|
||||
|
||||
**下标 = 1**
|
||||
|
||||
- `下标 < 行数`
|
||||
|
||||
**当前 = 下标**
|
||||
|
||||
**新顺序 = []**
|
||||
|
||||
**已插入 = false**
|
||||
|
||||
**位 = 0**
|
||||
|
||||
- `位 < 长度(顺序)`
|
||||
|
||||
**已有 = 顺序[位]**
|
||||
|
||||
1. `not 已插入 and 数据[目标列][已有] > 数据[目标列][当前]`
|
||||
|
||||
**新顺序 = list.append(新顺序, 当前)**
|
||||
|
||||
**新顺序 = list.append(新顺序, 已有)**
|
||||
|
||||
**已插入 = true**
|
||||
|
||||
2. `true`
|
||||
|
||||
**新顺序 = list.append(新顺序, 已有)**
|
||||
|
||||
**位 = 位 + 1**
|
||||
|
||||
1. `not 已插入`
|
||||
|
||||
**新顺序 = list.append(新顺序, 当前)**
|
||||
|
||||
2. `true`
|
||||
|
||||
**忽略 = 0**
|
||||
|
||||
**顺序 = 新顺序**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
**新数据 = []**
|
||||
|
||||
**列号 = 0**
|
||||
|
||||
- `列号 < 长度(列)`
|
||||
|
||||
**新列 = []**
|
||||
|
||||
**位 = 0**
|
||||
|
||||
- `位 < 行数`
|
||||
|
||||
**新列 = list.append(新列, 数据[列号][顺序[位]])**
|
||||
|
||||
**位 = 位 + 1**
|
||||
|
||||
**新数据 = list.append(新数据, 新列)**
|
||||
|
||||
**列号 = 列号 + 1**
|
||||
|
||||
*{列: 列, 数据: 新数据}*
|
||||
|
||||
## 列存过滤
|
||||
|
||||
`(列存, 目标列, 阈值)`
|
||||
|
||||
**列 = 列存["列"]**
|
||||
|
||||
**数据 = 列存["数据"]**
|
||||
|
||||
**行数 = 长度(数据[目标列])**
|
||||
|
||||
**保留 = []**
|
||||
|
||||
**行号 = 0**
|
||||
|
||||
- `行号 < 行数`
|
||||
|
||||
1. `数据[目标列][行号] > 阈值`
|
||||
|
||||
**保留 = list.append(保留, 行号)**
|
||||
|
||||
2. `true`
|
||||
|
||||
**忽略 = 0**
|
||||
|
||||
**行号 = 行号 + 1**
|
||||
|
||||
**新数据 = []**
|
||||
|
||||
**列号 = 0**
|
||||
|
||||
- `列号 < 长度(列)`
|
||||
|
||||
**新列 = []**
|
||||
|
||||
**位 = 0**
|
||||
|
||||
- `位 < 长度(保留)`
|
||||
|
||||
**新列 = list.append(新列, 数据[列号][保留[位]])**
|
||||
|
||||
**位 = 位 + 1**
|
||||
|
||||
**新数据 = list.append(新数据, 新列)**
|
||||
|
||||
**列号 = 列号 + 1**
|
||||
|
||||
*{列: 列, 数据: 新数据}*
|
||||
|
||||
## 表相等
|
||||
|
||||
`(左, 右)`
|
||||
|
||||
**左列 = table.columns(左)**
|
||||
|
||||
**右列 = table.columns(右)**
|
||||
|
||||
**相等 = 长度(左列) == 长度(右列) and 长度(左) == 长度(右)**
|
||||
|
||||
**列号 = 0**
|
||||
|
||||
- `列号 < 长度(左列) and 相等`
|
||||
|
||||
1. `左列[列号] != 右列[列号]`
|
||||
|
||||
**相等 = false**
|
||||
|
||||
2. `true`
|
||||
|
||||
**忽略 = 0**
|
||||
|
||||
**列号 = 列号 + 1**
|
||||
|
||||
**行号 = 0**
|
||||
|
||||
- `行号 < 长度(左) and 相等`
|
||||
|
||||
**列号 = 0**
|
||||
|
||||
- `列号 < 长度(左列) and 相等`
|
||||
|
||||
1. `table.cell(左, 行号, 列号) != table.cell(右, 行号, 列号)`
|
||||
|
||||
**相等 = false**
|
||||
|
||||
2. `true`
|
||||
|
||||
**忽略 = 0**
|
||||
|
||||
**列号 = 列号 + 1**
|
||||
|
||||
**行号 = 行号 + 1**
|
||||
|
||||
*相等*
|
||||
|
||||
## main
|
||||
|
||||
**列存 = {列: ["名称", "分数"], 数据: [["甲", "乙", "丙"], [87, 92, 71]]}**
|
||||
|
||||
**行表 = 转表(列存)**
|
||||
|
||||
**排序行 = 数据表.排序(行表, 1)**
|
||||
|
||||
**排序列 = 转表(列存排序(列存, 1))**
|
||||
|
||||
**过滤行 = 数据表.过滤数值大于(行表, 1, 80)**
|
||||
|
||||
**过滤列 = 转表(列存过滤(列存, 1, 80))**
|
||||
|
||||
*[表相等(转表(列存), 行表), 表相等(排序行, 排序列), 表相等(过滤行, 过滤列)]*
|
||||
Reference in new issue
Block a user