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:
1 parent
e1c4da4cc5
commit
053ddb0e59
19 files changed
+949
-6
No files matched your search
@@ -0,0 +1,42 @@
|
||||
|
||||
# @exec random
|
||||
## 字节
|
||||
|
||||
`params(数量)`
|
||||
|
||||
读取 数量 个 OS 熵字节,返回 List<Int>(每个 0–255)。仅项目模式,
|
||||
需要显式 --allow-random;pure/strict 拒绝。
|
||||
|
||||
`return resource.request("random.bytes", [数量])`
|
||||
|
||||
## 整数
|
||||
|
||||
`params(上限)`
|
||||
|
||||
返回 0 <= 值 < 上限 的整数。上限 必须大于 0;使用 8 个熵字节
|
||||
组合后取模(无偏拒绝采样尚未实现)。
|
||||
|
||||
`if 上限 <= 0`
|
||||
|
||||
`return {ok: false, code: "random.invalid", message: "上限必须大于 0"}`
|
||||
|
||||
`end`
|
||||
**字节结果 = 字节(8)**
|
||||
|
||||
`if not 字节结果.ok`
|
||||
|
||||
`return 字节结果`
|
||||
|
||||
`end`
|
||||
**值 = 0**
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
`while 下标 < 8`
|
||||
|
||||
**值 = 值 * 256 + 字节结果.value[下标]**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
`end`
|
||||
`return {ok: true, value: 值 % 上限}`
|
||||
Reference in new issue
Block a user