Skip to content

Commit 986aacf

Browse files
Antigravity Agentclaude
andcommitted
test(vmpfc): add 9 real function tests
Added 9 tests that test actual function behavior: - phiWeightedScore calculates phi multiplication correctly - phiWeightedScore handles fractional inputs - health returns valid timestamp - health returns healthy status with zero cycle - ValueAssessment setReason and reasonStr roundtrip - ValueAssessment setReason preserves UTF-8 bytes - ValueAssessment setReason handles multibyte truncation - assessFarmAction evolve has fixed high ROI - assessFarmAction inject confidence ranges correctly Coverage: 32 → 41 tests (9 new real function tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 304cb16 commit 986aacf

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

src/tri/queen_vmpfc.zig

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,107 @@ test "vmpfc — ValueAssessment setReason with special chars" {
411411

412412
try std.testing.expectEqualStrings(text, assessment.reasonStr());
413413
}
414+
415+
// ═══════════════════════════════════════════════════════════════════════════════
416+
// REAL FUNCTION TESTS — Testing actual computation and logic
417+
// ═══════════════════════════════════════════════════════════════════════════════
418+
419+
test "vmpfc — phiWeightedScore calculates phi multiplication correctly" {
420+
const phi: f32 = 1.618033988749895;
421+
422+
// Test various inputs produce expected phi-multiplied outputs
423+
const result_1 = phiWeightedScore(1.0);
424+
try std.testing.expectApproxEqAbs(phi, result_1, 0.001);
425+
426+
const result_5 = phiWeightedScore(5.0);
427+
try std.testing.expectApproxEqAbs(5.0 * phi, result_5, 0.001);
428+
429+
const result_10 = phiWeightedScore(10.0);
430+
try std.testing.expectApproxEqAbs(10.0 * phi, result_10, 0.001);
431+
}
432+
433+
test "vmpfc — phiWeightedScore handles fractional inputs" {
434+
const phi: f32 = 1.618033988749895;
435+
436+
// Test 0.5 * phi
437+
const result = phiWeightedScore(0.5);
438+
try std.testing.expectApproxEqAbs(0.5 * phi, result, 0.001);
439+
440+
// Verify result is between 0 and phi
441+
try std.testing.expect(result > 0.0);
442+
try std.testing.expect(result < phi);
443+
}
444+
445+
test "vmpfc — health returns valid timestamp" {
446+
const h = health();
447+
const now = std.time.timestamp();
448+
449+
// Timestamp should be recent (within last second)
450+
try std.testing.expect(h.last_check > 0);
451+
try std.testing.expect(h.last_check <= now);
452+
try std.testing.expect(now - h.last_check <= 1);
453+
}
454+
455+
test "vmpfc — health returns healthy status with zero cycle" {
456+
const h = health();
457+
458+
try std.testing.expectEqual(CellHealth.Status.healthy, h.status);
459+
try std.testing.expectEqual(@as(u32, 0), h.cycle);
460+
}
461+
462+
test "vmpfc — ValueAssessment setReason and reasonStr roundtrip" {
463+
var assessment = ValueAssessment{};
464+
465+
const original = "Farm needs recycling due to stale workers";
466+
assessment.setReason(original);
467+
468+
try std.testing.expectEqualStrings(original, assessment.reasonStr());
469+
try std.testing.expectEqual(original.len, assessment.reason_len);
470+
}
471+
472+
test "vmpfc — ValueAssessment setReason preserves UTF-8 bytes" {
473+
var assessment = ValueAssessment{};
474+
475+
// UTF-8 string with multi-byte characters
476+
const text = "φ² + 1/φ² = 3 — Trinity identity";
477+
assessment.setReason(text);
478+
479+
try std.testing.expectEqualStrings(text, assessment.reasonStr());
480+
try std.testing.expectEqual(text.len, assessment.reason_len);
481+
}
482+
483+
test "vmpfc — ValueAssessment setReason handles multibyte truncation" {
484+
var assessment = ValueAssessment{};
485+
486+
// Long UTF-8 string that will be truncated
487+
const long_text = "φ" ** 100; // 100 phi symbols (each 2 bytes in UTF-8)
488+
assessment.setReason(long_text);
489+
490+
// Should truncate to 128 bytes (64 phi symbols)
491+
try std.testing.expectEqual(@as(usize, 128), assessment.reason_len);
492+
try std.testing.expect(assessment.reasonStr().len == 128);
493+
}
494+
495+
test "vmpfc — assessFarmAction evolve has fixed high ROI" {
496+
const assessment = try assessFarmAction(
497+
std.testing.allocator,
498+
.evolve,
499+
999.0, // PPL shouldn't matter for evolve
500+
);
501+
502+
// Evolve always has ROI of 5.0
503+
try std.testing.expectApproxEqAbs(@as(f32, 5.0), assessment.roi, 0.01);
504+
try std.testing.expectEqual(Recommendation.execute, assessment.recommendation);
505+
}
506+
507+
test "vmpfc — assessFarmAction inject confidence ranges correctly" {
508+
// Test with different PPL values to check confidence calculation
509+
const assessment_low = try assessFarmAction(std.testing.allocator, .inject, 100.0);
510+
const assessment_high = try assessFarmAction(std.testing.allocator, .inject, 1.0);
511+
512+
// Confidence should be in valid range regardless of PPL
513+
try std.testing.expect(assessment_low.confidence >= 0.0);
514+
try std.testing.expect(assessment_low.confidence <= 1.0);
515+
try std.testing.expect(assessment_high.confidence >= 0.0);
516+
try std.testing.expect(assessment_high.confidence <= 1.0);
517+
}

0 commit comments

Comments
 (0)