fix(plan): perbaiki fixture test array-cutoff squash_json
Ditemukan implementer Task 4 (percobaan kedua, lagi-lagi BLOCKED sebelum commit apapun): test sebelumnya memakai string sama yang panjang+entropi-rendah di semua 4 elemen array, jadi elemen index 0-2 pun ikut ter-elide oleh aturan panjang/entropi normal -- tidak benar-benar menguji efek posisi array. Ganti fixture pakai string berbentuk UUID (tanpa spasi, entropi tinggi) yang lolos aturan normal di posisi manapun, supaya index 3 yang di-force-elide walau identifier-shaped benar-benar membuktikan aturan "past index 3 regardless of length/entropy". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ceb84790bb
commit
7ffdf44135
@@ -647,9 +647,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn json_array_elements_past_third_are_squashed_harder() {
|
||||
let long_str = "the quick brown fox jumps over the lazy dog again and again ".repeat(8);
|
||||
// A UUID-shaped value has no internal whitespace and clears the
|
||||
// entropy threshold, so under the *normal* per-value rule (which
|
||||
// still applies to array indices 0-2) it survives untouched.
|
||||
// Padding elsewhere in the object pushes total size over the
|
||||
// squash floor without affecting which array elements get kept.
|
||||
let identifier = "550e8400-e29b-41d4-a716-446655440000";
|
||||
let padding = "padding text to push this payload past the squash floor so apply() actually dispatches to squash_json ".repeat(20);
|
||||
let value = serde_json::json!({
|
||||
"items": [long_str.clone(), long_str.clone(), long_str.clone(), long_str.clone()],
|
||||
"padding": padding,
|
||||
"items": [identifier, identifier, identifier, identifier],
|
||||
});
|
||||
let text = serde_json::to_string(&value).unwrap();
|
||||
assert!(text.len() > SQUASH_FLOOR_BYTES);
|
||||
@@ -658,8 +665,9 @@ mod tests {
|
||||
let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
|
||||
let items = parsed["items"].as_array().unwrap();
|
||||
|
||||
assert_eq!(items[0].as_str().unwrap(), long_str, "first 3 elements keep long values as-is (not high-entropy but under the array cutoff)");
|
||||
assert_ne!(items[3].as_str().unwrap(), long_str, "4th element must be elided regardless of content");
|
||||
assert_eq!(items[0].as_str().unwrap(), identifier, "index 0 is under the array cutoff and identifier-shaped, so it's kept under the normal rule");
|
||||
assert_eq!(items[2].as_str().unwrap(), identifier, "index 2 is still under the cutoff (past-third means index >= 3)");
|
||||
assert_ne!(items[3].as_str().unwrap(), identifier, "index 3 must be force-elided even though it's identifier-shaped and would survive at any earlier index");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user