Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/campaign/edge_case_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sort"
"strings"
"time"
"math"

"codenerd/internal/core"
"codenerd/internal/logging"
Expand Down Expand Up @@ -585,6 +586,9 @@ func (d *EdgeCaseDetector) parseNumber(arg interface{}) (float64, bool) {
case float32:
return float64(v), true
case float64:
if math.IsNaN(v) || math.IsInf(v, 0) {
return 0, false
}
return v, true
default:
return 0, false
Expand Down
8 changes: 4 additions & 4 deletions internal/campaign/edge_case_detector_gaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ func TestEdgeCaseDetectorGap_TypeCoercion(t *testing.T) {
detector := NewEdgeCaseDetector(nil, nil)

// Test NaN
nanVal, ok := detector.parseNumber(math.NaN())
if !ok || !math.IsNaN(nanVal) {
_, ok := detector.parseNumber(math.NaN())
if ok {
t.Errorf("parseNumber failed to handle NaN")
}

// Test Inf
infVal, ok := detector.parseNumber(math.Inf(1))
if !ok || !math.IsInf(infVal, 1) {
_, ok = detector.parseNumber(math.Inf(1))
if ok {
t.Errorf("parseNumber failed to handle Inf")
}

Expand Down
23 changes: 19 additions & 4 deletions internal/campaign/edge_case_detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package campaign

import (
"context"
"math"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -307,10 +308,24 @@ func TestEdgeCaseAnalysis_FileCategories(t *testing.T) {
// Test with `IntelligenceReport{FileTopology: map[string]FileInfo{}, GitChurnHotspots: []GitChurn{}}`.
// Expected behavior: Should default to ActionCreate gracefully.

// TODO: Missing Edge Case - Type Coercion: parseNumber handling NaN and +Inf.
// Test passing a float64 representing math.NaN() or math.Inf(1) to parseNumber.
// Expected behavior: If Mangle returns an anomalous float, complexity should not become infinite
// or cause ActionRefactorFirst permanently.
func TestEdgeCaseDetector_ParseNumber_AnomalousFloat(t *testing.T) {
d := NewEdgeCaseDetector(nil, nil)

// Test NaN
if _, ok := d.parseNumber(math.NaN()); ok {
t.Error("parseNumber should return false for NaN")
}

// Test +Inf
if _, ok := d.parseNumber(math.Inf(1)); ok {
t.Error("parseNumber should return false for +Inf")
}

// Test -Inf
if _, ok := d.parseNumber(math.Inf(-1)); ok {
t.Error("parseNumber should return false for -Inf")
}
}

// TODO: Missing Edge Case - User Request Extremes: Unknown file extensions.
// Test `detectLanguage` with an esoteric extension like `.zig` or `.mojo` or `.xyz`.
Expand Down