test(rfc-cm): close P2 evidence gaps for C01/C06/C12

- Add alloc.double_free detection to the .mq.md free-list allocator and a
  fixture assertion for a second free returning a recoverable Result.
- Add table group fixture 69 (table.row -> Map of value lists).
- Add Int matrix-multiply fixture 70 for C12 layout/iteration.
- Update counts and P2 evidence/status docs.

Gate: fmt, clippy -D warnings, 407 tests passed.
This commit is contained in:
cflmy committed 2026-11-20 21:22:44 +08:00
1 parent 92bfbf2568
commit 5d3a5fb13b
12 files changed
+414 -11

No files matched your search

+8 -2
View File
@@ -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/ 68 × *.mq.md + sibling *.expected.json goldens
│ └── semantics/ 70 × *.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
@@ -163,7 +163,13 @@ by:
tables remain unchanged;
* semantic fixture 68: a quoted/escaped CSV single-row parser using Unicode
scalar primitives; `""` is a literal quote and commas inside quotes are
preserved. Multi-line fields and whitespace trimming are out of scope.
preserved. Multi-line fields and whitespace trimming are out of scope;
* semantic fixture 69: table group by a Text key column into a `Map` of value
lists, using `table.row/cell`, `map.has/get/set` and `list.append`;
* semantic fixture 70: Int matrix multiply over list-of-list row-major data,
covering C12's layout/iteration shape without a numeric backend;
* fixture 55 additionally has a second-free detection path: freeing an
already-free block returns `{ok:false, code:"alloc.double_free"}`.
RFC-CM CM-A07 Compat-A (ADR-0027) is pinned by:
@@ -220,6 +220,35 @@
},
"type": "map"
},
{
"entries": {
"ok": {
"type": "bool",
"value": true
},
"value": {
"type": "none"
}
},
"type": "map"
},
{
"entries": {
"code": {
"type": "text",
"value": "alloc.double_free"
},
"message": {
"type": "text",
"value": "块已在空闲链表"
},
"ok": {
"type": "bool",
"value": false
}
},
"type": "map"
},
{
"decimal": "33",
"type": "int"
@@ -221,14 +221,40 @@ first-fit:先查空闲链表,必要时切分;否则从 bump 指针处取
*成功(None)*
## 已在空闲表
`(内存, 块)`
线性扫描空闲链表,检测重复释放。
**当前 = 读32(内存, 0)**
**结果 = false**
- `当前 != 0 and not 结果`
1. `当前 == 块`
**结果 = true**
2. `true`
**当前 = 读32(内存, 当前 + 4)**
*结果*
## 释放
`(内存, 地址)`
把 payload 偏移换算回块头,按地址插入空闲链表并由“合并”处理相邻块。
把 payload 偏移换算回块头;重复释放返回可恢复错误,正常释放按地址插入并由“合并”处理相邻块。
**块 = 地址 - 8**
1. `已在空闲表(内存, 块)`
*失败("alloc.double_free", "块已在空闲链表")*
> 插入空闲(内存, 块)
*成功(None)*
@@ -305,4 +331,8 @@ first-fit:先查空闲链表,必要时切分;否则从 bump 指针处取
**戊2 = 分配(内存2, 65536, 8)**
*[甲, 乙, 丙, 丁, 戊, 己, 庚, 辛, 壬, 癸, 失败结果, 甲2, 乙2, 丙2, 丁2, 戊2, 内存[甲.value], 内存[乙.value], 内存[丙.value], 内存[丁.value], 内存[戊.value], 内存[庚.value], 内存[辛.value], 内存[壬.value], 内存[癸.value]]*
**释放一次 = 释放(内存2, 丁2.value)**
**重复释放 = 释放(内存2, 丁2.value)**
*[甲, 乙, 丙, 丁, 戊, 己, 庚, 辛, 壬, 癸, 失败结果, 甲2, 乙2, 丙2, 丁2, 戊2, 释放一次, 重复释放, 内存[甲.value], 内存[乙.value], 内存[丙.value], 内存[丁.value], 内存[戊.value], 内存[庚.value], 内存[辛.value], 内存[壬.value], 内存[癸.value]]*
@@ -0,0 +1,104 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"items": [
{
"header": [
"类别",
"值"
],
"rows": [
[
{
"type": "text",
"value": "a"
},
{
"decimal": "1",
"type": "int"
}
],
[
{
"type": "text",
"value": "b"
},
{
"decimal": "2",
"type": "int"
}
],
[
{
"type": "text",
"value": "a"
},
{
"decimal": "3",
"type": "int"
}
],
[
{
"type": "text",
"value": "b"
},
{
"decimal": "4",
"type": "int"
}
],
[
{
"type": "text",
"value": "a"
},
{
"decimal": "5",
"type": "int"
}
]
],
"type": "table"
},
{
"entries": {
"a": {
"items": [
{
"decimal": "1",
"type": "int"
},
{
"decimal": "3",
"type": "int"
},
{
"decimal": "5",
"type": "int"
}
],
"type": "list"
},
"b": {
"items": [
{
"decimal": "2",
"type": "int"
},
{
"decimal": "4",
"type": "int"
}
],
"type": "list"
}
},
"type": "map"
}
],
"type": "list"
}
}
@@ -0,0 +1,41 @@
## 分组
`(数据, 键列, 值列)`
按文本键列分组,把值列聚合成 Map:键 -> List。输入表不变。
**结果 = {}**
**行号 = 0**
- `行号 < 长度(数据)`
**行 = table.row(数据, 行号)**
**键 = 行[键列]**
**当前 = map.get(结果, 键)**
**列表 = []**
1. `map.has(结果, 键)`
**列表 = 当前**
2. `true`
**忽略 = 0**
**列表 = list.append(列表, 行[值列])**
**结果 = map.set(结果, 键, 列表)**
**行号 = 行号 + 1**
*结果*
## main
**数据 = 表(["类别", "值"], [["a", 1], ["b", 2], ["a", 3], ["b", 4], ["a", 5]])**
*[数据, 分组(数据, 0, 1)]*
@@ -0,0 +1,124 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"items": [
{
"items": [
{
"items": [
{
"decimal": "1",
"type": "int"
},
{
"decimal": "2",
"type": "int"
},
{
"decimal": "3",
"type": "int"
}
],
"type": "list"
},
{
"items": [
{
"decimal": "4",
"type": "int"
},
{
"decimal": "5",
"type": "int"
},
{
"decimal": "6",
"type": "int"
}
],
"type": "list"
}
],
"type": "list"
},
{
"items": [
{
"items": [
{
"decimal": "7",
"type": "int"
},
{
"decimal": "8",
"type": "int"
}
],
"type": "list"
},
{
"items": [
{
"decimal": "9",
"type": "int"
},
{
"decimal": "10",
"type": "int"
}
],
"type": "list"
},
{
"items": [
{
"decimal": "11",
"type": "int"
},
{
"decimal": "12",
"type": "int"
}
],
"type": "list"
}
],
"type": "list"
},
{
"items": [
{
"items": [
{
"decimal": "58",
"type": "int"
},
{
"decimal": "64",
"type": "int"
}
],
"type": "list"
},
{
"items": [
{
"decimal": "139",
"type": "int"
},
{
"decimal": "154",
"type": "int"
}
],
"type": "list"
}
],
"type": "list"
}
],
"type": "list"
}
}
@@ -0,0 +1,47 @@
## 矩阵乘
`(左, 右)`
List-of-List 行主序矩阵乘法;调用方保证维度匹配。使用 Int 精确算术。
**结果 = []**
**行号 = 0**
- `行号 < 长度(左)`
**左行 = 左[行号]**
**新行 = []**
**列号 = 0**
- `列号 < 长度(右[0])`
**总和 = 0**
**内号 = 0**
- `内号 < 长度(左行)`
**总和 = 总和 + 左行[内号] * 右[内号][列号]**
**内号 = 内号 + 1**
**新行 = list.append(新行, 总和)**
**列号 = 列号 + 1**
**结果 = list.append(结果, 新行)**
**行号 = 行号 + 1**
*结果*
## main
**左 = [[1, 2, 3], [4, 5, 6]]**
**右 = [[7, 8], [9, 10], [11, 12]]**
*[左, 右, 矩阵乘(左, 右)]*