/
nv-lang
/
nova
Обзор
Документация
Войти
/
nv-lang
/
nova
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
std/src/text/diff_test.nv
56 строк
1 KB
Evgeniy Golovin
195: std/ -> std/src/ (git mv, module-path без изменений)
13 июл 2026, 01:13
13 июл 2026, 01:13
be4fcab
Код
Авторство
О чём код?
// SPDX-License-Identifier: MIT OR Apache-2.0 // std/text/diff_test.nv — публичный контракт Diff.compute/format (Myers diff). module text.diff_test import std.text.diff.{Diff, DiffOp} test "diff: identical arrays" { ro ops = Diff.compute(["a", "b", "c"], ["a", "b", "c"]) for op in ops { match op { DiffOp.Equal(_) => () _ => assert(false) } } } test "diff: complete change" { ro ops = Diff.compute(["a"], ["b"]) // Должна быть Delete("a") + Insert("b") mut has_delete = false mut has_insert = false for op in ops { match op { DiffOp.Delete("a") => { has_delete = true } DiffOp.Insert("b") => { has_insert = true } _ => () } } assert(has_delete) assert(has_insert) } test "diff: insertion в середине" { ro ops = Diff.compute(["a", "c"], ["a", "b", "c"]) mut has_insert_b = false for op in ops { match op { DiffOp.Insert("b") => { has_insert_b = true } _ => () } } assert(has_insert_b) } test "diff: deletion в середине" { ro ops = Diff.compute(["a", "b", "c"], ["a", "c"]) mut has_delete_b = false for op in ops { match op { DiffOp.Delete("b") => { has_delete_b = true } _ => () } } assert(has_delete_b) }