migrate: own clock/datetime/env/process/random sources and baseline assertions

Move the official stdlib system modules to their unique source authority without
changing public std: paths or host authorization. Carry the pre-migration product
assertions into component cases captured from the baseline Bundle; the process
case resolves the granted program and expected stdout from the verified CLI.

Refs cflmy/marqdo#9, cflmy/marqdo-std-system#1
This commit was merged in pull request #2.
This commit is contained in:
cflmy committed 2026-11-26 23:30:25 +08:00
1 parent e1c4da4cc5
commit 053ddb0e59
19 files changed
+949 -6

No files matched your search

+5 -1
View File
@@ -1,3 +1,7 @@
# 验收测试
首个功能附带正例和失败用例,记录所用 CLI 提交或发行版本以及实际运行命令。
`tests/*.mq.md` 是从迁移前 CLI 官方标准库自测迁入的真实测试源;`tests/cases/*.json` 固定每个测试的输入(stdin、CLI 参数、环境、所需 Bundle 模块)和期望结果(observation 终值、stdout、必要的资源事件)。
运行入口是 `scripts/test.sh`,它要求显式传入 `MARQDO_BIN` 与 `MARQDO_STDLIB_DIR`。缺少制品、Bundle 缺少模块或 digest 校验失败时必须失败,不得回退到其它目录。
期望值取自迁移前基线 Bundle(`sha256:5407d36...`)与已验证候选 CLI 的真实执行结果;任何期望值改动都必须作为公开行为变化单独评审并记录证据。
+28
View File
@@ -0,0 +1,28 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "clock",
"file": "clock.mq.md",
"require_module": "clock.mq.md",
"args": [],
"stdin": "",
"env": {},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"type": "bool",
"value": true
},
{
"type": "text",
"value": "Int"
},
{
"type": "bool",
"value": true
}
],
"type": "list"
}
}
+44
View File
@@ -0,0 +1,44 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "datetime",
"file": "datetime.mq.md",
"require_module": "datetime.mq.md",
"args": [],
"stdin": "",
"env": {},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"type": "text",
"value": "1970-01-01T00:00:00Z"
},
{
"type": "text",
"value": "2023-11-14T22:13:20.123Z"
},
{
"decimal": "0",
"type": "int"
},
{
"decimal": "1795248000123",
"type": "int"
},
{
"type": "bool",
"value": false
},
{
"type": "bool",
"value": false
},
{
"type": "text",
"value": "1969-12-31T23:59:59.999Z"
}
],
"type": "list"
}
}
+47
View File
@@ -0,0 +1,47 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "env",
"file": "env.mq.md",
"require_module": "env.mq.md",
"args": [
"--allow-env",
"MARQDO_TEST_ENV",
"--allow-env",
"MARQDO_MISSING_ENV"
],
"stdin": "",
"env": {
"MARQDO_TEST_ENV": "env-value"
},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"type": "bool",
"value": true
},
{
"type": "bool",
"value": true
},
{
"type": "bool",
"value": true
},
{
"type": "text",
"value": "env-value"
},
{
"type": "bool",
"value": false
},
{
"type": "text",
"value": "env.not_found"
}
],
"type": "list"
}
}
+41
View File
@@ -0,0 +1,41 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "process",
"file": "process.mq.md",
"require_module": "process.mq.md",
"args": [
"--allow-env",
"MARQDO_TEST_PROCESS_PROGRAM",
"--allow-process",
"$MARQDO_BIN"
],
"stdin": "",
"env": {
"MARQDO_TEST_PROCESS_PROGRAM": "$MARQDO_BIN"
},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"type": "bool",
"value": true
},
{
"decimal": "0",
"type": "int"
},
{
"type": "text",
"value": {
"$bin_version": true
}
},
{
"type": "text",
"value": ""
}
],
"type": "list"
}
}
+38
View File
@@ -0,0 +1,38 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "random",
"file": "random.mq.md",
"require_module": "random.mq.md",
"args": [
"--allow-random"
],
"stdin": "",
"env": {},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"type": "bool",
"value": true
},
{
"decimal": "16",
"type": "int"
},
{
"type": "bool",
"value": true
},
{
"type": "bool",
"value": true
},
{
"type": "bool",
"value": true
}
],
"type": "list"
}
}
+12
View File
@@ -0,0 +1,12 @@
---
import:
clock: "std:clock"
---
# @exec clock
## main
**现在 = clock.现在()**
`return [现在.ok, 类型(现在.value), 现在.value > 1600000000000]`
+10
View File
@@ -0,0 +1,10 @@
---
import:
datetime: "std:datetime"
---
# @exec datetime
## main
`return [datetime.格式化(0), datetime.格式化(1700000000123), datetime.解析("1970-01-01T00:00:00Z").value, datetime.解析("2026-11-21T08:00:00.123Z").value, datetime.解析("2026-13-01T00:00:00Z").ok, datetime.解析("2026-02-29T00:00:00Z").ok, datetime.格式化(-1)]`
+16
View File
@@ -0,0 +1,16 @@
---
import:
env: "std:env"
---
# @exec env
## main
**存在 = env.存在("MARQDO_TEST_ENV")**
**读取 = env.读取("MARQDO_TEST_ENV")**
**缺失 = env.读取("MARQDO_MISSING_ENV")**
`return [存在.ok, 存在.value, 读取.ok, 读取.value, 缺失.ok, 缺失.code]`
+15
View File
@@ -0,0 +1,15 @@
---
import:
env: "std:env"
process: "std:process"
---
# @exec process
## main
**程序 = env.读取("MARQDO_TEST_PROCESS_PROGRAM")**
**结果 = process.运行(程序.value, ["--version"])**
`return [结果.ok, 结果.value.status, 结果.value.stdout, 结果.value.stderr]`
+14
View File
@@ -0,0 +1,14 @@
---
import:
random: "std:random"
---
# @exec random
## main
**字节结果 = random.字节(16)**
**整数结果 = random.整数(100)**
`return [字节结果.ok, 长度(字节结果.value), 整数结果.ok, 整数结果.value >= 0, 整数结果.value < 100]`