migrate: own JSON/CSV and Table serialization; drop the value algorithms

Move JSON, CSV and the Table serialization half of the frozen module to their
unique source authority. Value operations now live only in std-collections;
there is no second implementation or legacy forwarder. Baseline JSON/CSV and
Table GFM expectations are carried into component cases.

Refs cflmy/marqdo#9, cflmy/marqdo-std-data#1
This commit was merged in pull request #2.
This commit is contained in:
cflmy committed 2026-11-26 23:32:22 +08:00
1 parent e3c9488dca
commit 848af7a357
13 files changed
+1948 -6

No files matched your search

+5 -1
View File
@@ -1,3 +1,7 @@
# 验收测试
首个功能附带正例和失败用例,记录所用 CLI 提交或发行版本以及实际运行命令。
`tests/*.mq.md` 是迁移期保留的真实测试源;`tests/cases/*.json` 固定输入(stdin、CLI 参数、环境、所需 Bundle 模块)与期望结果(observation 终值、stdout、必要的资源事件)。
运行入口是 `scripts/test.sh`,要求显式传入 `MARQDO_BIN` 与 `MARQDO_STDLIB_DIR`。缺少制品、Bundle 缺少模块或 digest 校验失败时必须失败,不得回退到其它目录。
期望值取自迁移前基线 Bundle 的真实执行结果;修改期望值等于声明公开行为变化,必须单独评审。
+102
View File
@@ -0,0 +1,102 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "csv",
"file": "csv.mq.md",
"require_module": "data/csv.mq.md",
"args": [],
"stdin": "",
"env": {},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"items": [
{
"type": "text",
"value": "甲"
},
{
"type": "text",
"value": "乙,丙"
},
{
"type": "text",
"value": "说\"好"
}
],
"type": "list"
},
{
"type": "text",
"value": "甲,\"乙,丙\",\"说\"\"好\""
},
{
"items": [
{
"type": "text",
"value": ""
}
],
"type": "list"
},
{
"type": "text",
"value": "csv.unterminated_quote"
},
{
"items": [
{
"type": "text",
"value": "a"
},
{
"type": "text",
"value": "b"
}
],
"type": "list"
},
{
"type": "bool",
"value": true
},
{
"items": [
{
"items": [
{
"type": "text",
"value": "甲"
},
{
"type": "text",
"value": "乙,丙"
}
],
"type": "list"
},
{
"items": [
{
"type": "text",
"value": "说\"好"
},
{
"type": "text",
"value": "2"
}
],
"type": "list"
}
],
"type": "list"
},
{
"type": "text",
"value": "甲,\"乙,丙\"\n\"说\"\"好\",2"
}
],
"type": "list"
}
}
+78
View File
@@ -0,0 +1,78 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "json",
"file": "json.mq.md",
"require_module": "data/json.mq.md",
"args": [],
"stdin": "",
"env": {},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"type": "bool",
"value": true
},
{
"decimal": "1",
"type": "int"
},
{
"type": "text",
"value": "说\"好"
},
{
"type": "text",
"value": "[1, 2.5, -300.0, 0.4, {\"a\": 1.0}, \"x\"]"
},
{
"type": "bool",
"value": false
},
{
"type": "text",
"value": "json.invalid_array"
},
{
"type": "text",
"value": "json.trailing"
},
{
"type": "bool",
"value": false
},
{
"type": "text",
"value": "json.depth"
},
{
"type": "bool",
"value": true
},
{
"items": [
{
"decimal": "1",
"type": "int"
},
{
"decimal": "2",
"type": "int"
},
{
"items": [
{
"decimal": "3",
"type": "int"
}
],
"type": "list"
}
],
"type": "list"
}
],
"type": "list"
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "table",
"file": "table.mq.md",
"require_module": "data/table.mq.md",
"args": [],
"stdin": "",
"env": {},
"expected_stdout": "",
"expected_terminal": {
"type": "list",
"items": [
{
"type": "text",
"value": "| 名称 | 分数 |\n| --- | --- |\n| 甲 | 87 |\n| 乙 | 92 |\n| 丙 | 71 |"
}
]
}
}
+22
View File
@@ -0,0 +1,22 @@
---
import:
csv: "std:data/csv"
---
# @exec csv
## main
**`行 = csv.解析行("甲,\"乙,丙\",\"说\"\"好\"")`**
**`空 = csv.解析行("")`**
**`坏 = csv.解析行("\"a")`**
**`框 = csv.解析行("a,\"b\"")`**
**`多行 = csv.解析("甲,\"乙,丙\"\n\"说\"\"好\",2")`**
**格式化 = csv.格式化(多行.value)**
`return [行.value, csv.格式化行(行.value), 空.value, 坏.code, 框.value, 多行.ok, 多行.value, 格式化]`
+42
View File
@@ -0,0 +1,42 @@
---
import:
json: "std:data/json"
---
# @exec json
## main
**`对象 = json.解析("{\"a\": 1, \"b\": [true, null, \"说\\\"好\"]}")`**
**`浮点 = json.解析("[1, 2.5, -3e2, 4E-1, {\"a\": 1.0}, \"x\"]")`**
**`失败 = json.解析("[1 2]")`**
**`尾随 = json.解析("1 2")`**
**深度文本 = ""**
**深度下标 = 0**
`while 深度下标 < 130`
**深度文本 = 深度文本 + "["**
**深度下标 = 深度下标 + 1**
`end`
**深度下标 = 0**
`while 深度下标 < 130`
**深度文本 = 深度文本 + "]"**
**深度下标 = 深度下标 + 1**
`end`
**深度 = json.解析(深度文本)**
**`多个 = json.解析多个("1 2 [3]")`**
`return [对象.ok, 对象.value.a, 对象.value.b[2], json.格式化(浮点.value), 失败.ok, 失败.code, 尾随.code, 深度.ok, 深度.code, 多个.ok, 多个.value]`
+12
View File
@@ -0,0 +1,12 @@
---
import:
table_lib: "std:data/table"
---
# @exec table
## main
**数据 = 表(["名称", "分数"], [["甲", 87], ["乙", 92], ["丙", 71]])**
`return [table_lib.转GFM(数据)]`