fix: 修复字节码缓存未存值导致错误命中问题

This commit is contained in:
爱特每羊队
2026-06-06 14:30:31 +08:00
parent 1615f739d1
commit bca9f8995b
3 changed files with 43 additions and 2 deletions
+22 -1
View File
@@ -103,10 +103,31 @@ fn structural_hash_hit() {
#[test]
fn structural_hash_same_shape() {
let hash_a = parse_to_hash("var x = 1 + 2; var y = x;");
let hash_b = parse_to_hash("var a = 3 + 4; var b = a;");
let hash_b = parse_to_hash("var a = 1 + 2; var b = a;");
assert_eq!(hash_a, hash_b);
}
#[test]
fn structural_hash_different_init_values() {
let hash_a = parse_to_hash("var x = 1 + 2;");
let hash_b = parse_to_hash("var y = 3 + 4;");
assert_ne!(hash_a, hash_b);
}
#[test]
fn structural_hash_different_string_literals() {
let hash_a = parse_to_hash(r#"var x = "hello";"#);
let hash_b = parse_to_hash(r#"var x = "world";"#);
assert_ne!(hash_a, hash_b);
}
#[test]
fn structural_hash_different_booleans() {
let hash_a = parse_to_hash("var x = true;");
let hash_b = parse_to_hash("var x = false;");
assert_ne!(hash_a, hash_b);
}
#[test]
fn structural_hash_different_shape() {
let hash_a = parse_to_hash("1 + 2");