/
nv-lang
/
nova
Обзор
Документация
Войти
/
nv-lang
/
nova
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
spec_tests/conformance/json_roundtrip_array_empty.nv
33 строки
1 KB
Evgeniy Golovin
198 Ф.2 REDO: отмена pivot standalone-per-file — revert к D307-канону (шаг 1/N)
13 июл 2026, 01:29
13 июл 2026, 01:29
4394fec
Код
Авторство
О чём код?
// Plan 91.3 Ф.3 (composites conformance): JSON roundtrip — empty array. // // Validates encode/decode/roundtrip симметрию для пустого массива `[]`. // Empty-array edge: format_array должен не оставить trailing comma, // parser должен принять `[]` как `Array([])` (не throw). module spec_tests.conformance import std.encoding.json.{JsonValue, Json} test "encode empty array" { ro v = JsonValue.array([]) ro encoded = v.to_str() assert(encoded == "[]") } test "parse empty array" { ro parsed = Json.parse("[]")!! assert(parsed.is_array()) match parsed.array() { Some(xs) => assert(xs.len() == 0) None => assert(false) } } test "roundtrip empty array" { ro orig = JsonValue.array([]) ro encoded = orig.to_str() ro decoded = Json.parse(encoded)!! // Re-encode и сравнение через строку — JsonValue не имеет structural `==` // (D46 не покрывает sum-types per json.nv top comment). ro re_encoded = decoded.to_str() assert(re_encoded == encoded) }