Refactor: Rename map to record
This commit renames `Map` to `Record` and updates all related AST nodes, binders, type checkers, and runtime values to reflect this change. This is a semantic change to better align with common programming language terminology.
This commit is contained in:
@@ -201,26 +201,22 @@ mod tests {
|
||||
}
|
||||
|
||||
// Check runtime behavior
|
||||
if let Value::Tuple(t) = wrapped {
|
||||
if let Some(keys) = &t.keys {
|
||||
let idx = keys.iter().position(|k| *k == Keyword::intern("greet")).unwrap();
|
||||
let greet_fn = &t.values[idx];
|
||||
|
||||
if let Value::Function(f) = greet_fn {
|
||||
let res = f(vec![]);
|
||||
if let Value::Text(s) = res {
|
||||
assert_eq!(&*s, "Hello Alice");
|
||||
} else {
|
||||
panic!("Expected Text result");
|
||||
}
|
||||
if let Value::Record(r) = wrapped {
|
||||
let idx = r.keys.iter().position(|k| *k == Keyword::intern("greet")).unwrap();
|
||||
let greet_fn = &r.values[idx];
|
||||
|
||||
if let Value::Function(f) = greet_fn {
|
||||
let res = f(vec![]);
|
||||
if let Value::Text(s) = res {
|
||||
assert_eq!(&*s, "Hello Alice");
|
||||
} else {
|
||||
panic!("Expected Function value for method");
|
||||
panic!("Expected Text result");
|
||||
}
|
||||
} else {
|
||||
panic!("Expected Record keys");
|
||||
panic!("Expected Function value for method");
|
||||
}
|
||||
} else {
|
||||
panic!("Expected Tuple value");
|
||||
panic!("Expected Record value");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,19 +233,17 @@ mod tests {
|
||||
|
||||
if let Value::Function(f) = factory_val {
|
||||
let instance = f(vec![Value::Text("Bob".into()), Value::Int(40)]);
|
||||
if let Value::Tuple(t) = instance {
|
||||
if let Some(keys) = &t.keys {
|
||||
let idx = keys.iter().position(|k| *k == Keyword::intern("greet")).unwrap();
|
||||
let greet_fn = &t.values[idx];
|
||||
|
||||
if let Value::Function(gf) = greet_fn {
|
||||
let res = gf(vec![]);
|
||||
if let Value::Text(s) = res {
|
||||
assert_eq!(&*s, "Hello Bob");
|
||||
} else { panic!("Wrong return type"); }
|
||||
}
|
||||
} else { panic!("Expected keys"); }
|
||||
} else { panic!("Factory should return Tuple/Record"); }
|
||||
if let Value::Record(r) = instance {
|
||||
let idx = r.keys.iter().position(|k| *k == Keyword::intern("greet")).unwrap();
|
||||
let greet_fn = &r.values[idx];
|
||||
|
||||
if let Value::Function(gf) = greet_fn {
|
||||
let res = gf(vec![]);
|
||||
if let Value::Text(s) = res {
|
||||
assert_eq!(&*s, "Hello Bob");
|
||||
} else { panic!("Wrong return type"); }
|
||||
}
|
||||
} else { panic!("Factory should return Record"); }
|
||||
} else { panic!("Factory is not a function"); }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user