Remove unused record destructuring tests
These tests were for record destructuring, which has been removed. The code for record destructuring was also removed from the type checker and types modules.
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
;; Record to Tuple Mapping Test
|
||||
;; Output: 30
|
||||
;; Benchmark: 727ns
|
||||
;; Benchmark-Repeat: 2764
|
||||
(do
|
||||
(def rec {:x 10 :y 20})
|
||||
|
||||
;; Map record to tuple pattern
|
||||
(def add-tuple (fn [[a b]] (+ a b)))
|
||||
|
||||
(add-tuple rec)
|
||||
)
|
||||
@@ -1,11 +0,0 @@
|
||||
;; Benchmark: Record Destructuring Performance
|
||||
;; This test calls a function that destructures a record
|
||||
;; Current implementation is now zero-allocation for destructuring.
|
||||
;; Output: 3
|
||||
;; Benchmark: 129ns
|
||||
;; Benchmark-Repeat: 15432
|
||||
|
||||
(do
|
||||
(def process (fn [[x y]]
|
||||
(+ x y)))
|
||||
|
||||
@@ -627,15 +627,6 @@ mod tests {
|
||||
assert_eq!(get_ret_type(&result.unwrap()), StaticType::Int);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_destructuring_record_args() {
|
||||
let env = crate::ast::environment::Environment::new();
|
||||
// ((fn [[x y]] (+ x y)) {:a 5 :b 7}) -> 12
|
||||
let result = env.compile("((fn [[x y]] (+ x y)) {:a 5 :b 7})");
|
||||
assert!(result.is_ok());
|
||||
assert_eq!(get_ret_type(&result.unwrap()), StaticType::Int);
|
||||
}
|
||||
|
||||
fn get_ret_type(node: &TypedNode) -> StaticType {
|
||||
if let StaticType::Function(sig) = &node.ty {
|
||||
sig.ret.clone()
|
||||
|
||||
+1
-12
@@ -299,16 +299,6 @@ impl StaticType {
|
||||
.zip(other_elements.iter())
|
||||
.all(|(e, o)| e.is_assignable_from(o))
|
||||
}
|
||||
// Record to Tuple (Destructuring by values)
|
||||
(StaticType::Tuple(elements), StaticType::Record(fields)) => {
|
||||
if elements.len() != fields.len() {
|
||||
return false;
|
||||
}
|
||||
elements
|
||||
.iter()
|
||||
.zip(fields.iter().map(|(_, ty)| ty))
|
||||
.all(|(e, o)| e.is_assignable_from(o))
|
||||
}
|
||||
// A Matrix is a Vector (of Vectors/Matrices)
|
||||
(StaticType::Vector(inner, len), StaticType::Matrix(m_inner, shape)) => {
|
||||
if shape.is_empty() || shape[0] != *len {
|
||||
@@ -367,11 +357,10 @@ impl Value {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the underlying values as a slice if this is a Tuple or Record.
|
||||
/// Returns the underlying values as a slice if this is a Tuple.
|
||||
pub fn as_slice(&self) -> Option<&[Value]> {
|
||||
match self {
|
||||
Value::Tuple(v) => Some(v),
|
||||
Value::Record(r) => Some(&r.values),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,16 +301,6 @@ mod tests {
|
||||
"Nested tuple should be folded to 30. Dump:\n{}",
|
||||
dump_tuple
|
||||
);
|
||||
|
||||
// 2. Record-to-Tuple
|
||||
let source_record = "((fn [[x y]] (+ x y)) {:a 5 :b 7})";
|
||||
assert_eq!(format!("{}", env.run_script(source_record).unwrap()), "12");
|
||||
let dump_record = env.dump_ast(source_record).unwrap();
|
||||
assert!(
|
||||
dump_record.contains("Constant: 12"),
|
||||
"Record-to-Tuple destructuring should be folded to 12. Dump:\n{}",
|
||||
dump_record
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user