test-negative-offset-analysis.js•1.52 kB
/**
* Test Results: Negative Offset Analysis for read_file
*
* FINDINGS:
* ❌ Negative offsets DO NOT work correctly in the current implementation
* ❌ They return empty content due to invalid slice() range calculations
* ⚠️ The implementation has a bug when handling negative offsets
*
* CURRENT BEHAVIOR:
* - offset: -2, length: 5 → slice(-2, 3) → returns empty []
* - offset: -100, length: undefined → slice(-100, undefined) → works by accident
*
* RECOMMENDATION:
* Either fix the implementation to properly support negative offsets,
* or add validation to reject them with a clear error message.
*/
console.log("🔍 NEGATIVE OFFSET BEHAVIOR ANALYSIS");
console.log("====================================");
console.log("");
console.log("❌ CONCLUSION: Negative offsets are BROKEN in current implementation");
console.log("");
console.log("🐛 BUG DETAILS:");
console.log(" Current code: Math.min(offset, totalLines) creates invalid ranges");
console.log(" Example: offset=-2, totalLines=6 → slice(-2, 3) → empty result");
console.log("");
console.log("✅ ACCIDENTAL SUCCESS:");
console.log(" My original attempt worked because length was undefined");
console.log(" slice(-100, undefined) → slice(-100) → works correctly");
console.log("");
console.log("🔧 NEEDS FIX:");
console.log(" Either implement proper negative offset support or reject them");
export default async function runTests() {
return false; // Test documents that negative offsets are broken
}