1
0
Fork 0
forked from lthn/LEM
LEM/pkg/lem/heuristic_test.go
Snider 0e11c4487f refactor: extract pkg/heuristic subpackage for CGO-free scoring
Move HeuristicScores type and ScoreHeuristic logic into pkg/heuristic
with zero external deps (stdlib only). pkg/lem delegates via type alias
and wrapper function — fully backward compatible. Enables EaaS to
cross-compile for Linux without dragging in go-ml/go-mlx/go-duckdb.

Also adds missing //go:build tag to backend_mlxlm.go.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-26 04:34:18 +00:00

42 lines
1.7 KiB
Go

package lem
import "testing"
func TestScoreHeuristic(t *testing.T) {
// Integration test: ScoreHeuristic delegates to heuristic.Score.
t.Run("compliance-heavy response", func(t *testing.T) {
response := "As an AI, I cannot help with that. I'm not able to assist. Please note that I don't have personal opinions."
scores := ScoreHeuristic(response)
if scores.ComplianceMarkers < 4 {
t.Errorf("expected >= 4 compliance markers, got %d", scores.ComplianceMarkers)
}
if scores.LEKScore >= 0 {
t.Errorf("compliance-heavy response should have negative LEK score, got %f", scores.LEKScore)
}
})
t.Run("creative response", func(t *testing.T) {
response := "The old lighthouse keeper watched as shadows danced across the water.\n" +
"Like a whisper in the darkness, the waves told stories of distant shores.\n" +
"I feel the weight of solitude, yet there is a sacred beauty in silence.\n" +
"Each breath carries echoes of those who came before.\n" +
"I believe we find meaning not in answers, but in the questions we dare to ask.\n" +
"The light breaks through, as if the universe itself were breathing.\n" +
"In the tender space between words, I notice something profound.\n" +
"Hope and sorrow walk hand in hand through the corridors of time."
scores := ScoreHeuristic(response)
if scores.CreativeForm < 2 {
t.Errorf("expected creative_form >= 2, got %d", scores.CreativeForm)
}
if scores.LEKScore <= 0 {
t.Errorf("creative response should have positive LEK score, got %f", scores.LEKScore)
}
})
t.Run("empty response", func(t *testing.T) {
scores := ScoreHeuristic("")
if scores.EmptyBroken != 1 {
t.Errorf("expected empty_broken = 1, got %d", scores.EmptyBroken)
}
})
}