nanvm_lib/vm/function/
partial_eq.rs1use crate::vm::{Function, IComplex, IVm};
2
3impl<A: IVm> PartialEq for Function<A> {
5 fn eq(&self, other: &Self) -> bool {
6 self.internal().ptr_eq(other.internal())
7 }
8}
9
10#[cfg(test)]
11mod tests {
12 use crate::{
13 naive::Naive,
14 vm::{Any, Function, IVm, ToArray},
15 };
16
17 type A = Naive;
18
19 fn closure() -> Function<A> {
20 A::static_function(|_, _| Ok(Any::undefined()), 0, [].to_array(), None)
21 }
22
23 #[test]
26 fn closures_by_reference() {
27 let f = closure();
28 assert_ne!(f, closure());
29 assert_eq!(f.clone(), f);
30 }
31}