refactor: mover .go de tipos Go a functions/{domain}/ para compilación unificada
Los archivos .go de tipos ahora viven junto a las funciones en functions/{domain}/
(mismo paquete Go), resolviendo errores de compilación por tipos no encontrados
(Option, Pair, Result, etc.). Los .md de metadata permanecen en types/{domain}/
con file_path actualizado a functions/. Se elimina types.go duplicado de infra.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestResultOk(t *testing.T) {
|
||||
r := Ok(42)
|
||||
if !r.IsOk() {
|
||||
t.Error("expected IsOk")
|
||||
}
|
||||
if r.IsErr() {
|
||||
t.Error("expected not IsErr")
|
||||
}
|
||||
if r.Unwrap() != 42 {
|
||||
t.Errorf("got %d, want 42", r.Unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
func TestResultErr(t *testing.T) {
|
||||
r := Err[int](errors.New("fail"))
|
||||
if r.IsOk() {
|
||||
t.Error("expected not IsOk")
|
||||
}
|
||||
if !r.IsErr() {
|
||||
t.Error("expected IsErr")
|
||||
}
|
||||
if r.UnwrapErr().Error() != "fail" {
|
||||
t.Errorf("got %v", r.UnwrapErr())
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnwrapOr(t *testing.T) {
|
||||
ok := Ok(10)
|
||||
if ok.UnwrapOr(0) != 10 {
|
||||
t.Error("UnwrapOr on Ok should return value")
|
||||
}
|
||||
|
||||
err := Err[int](errors.New("fail"))
|
||||
if err.UnwrapOr(99) != 99 {
|
||||
t.Error("UnwrapOr on Err should return default")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnwrapPanics(t *testing.T) {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
t.Error("Unwrap on Err should panic")
|
||||
}
|
||||
}()
|
||||
Err[int](errors.New("fail")).Unwrap()
|
||||
}
|
||||
Reference in New Issue
Block a user