Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
sebffischer committed Oct 27, 2024
1 parent 6f734a1 commit 951f5e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/callable/primitive/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ impl Callable for PrimitiveQuote {
Ok(Obj::Expr(args.get(0).unwrap_or(Expr::Null)))
}
}

#[cfg(test)]

mod tests {
use crate::{r, r_expect};

#[test]
fn literals_dont_evaluate() {
r_expect!(typeof(quote(1)) == "expression")
}
}
10 changes: 9 additions & 1 deletion src/callable/primitive/substitute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Callable for PrimitiveSubstitute {

#[cfg(test)]
mod test {
use crate::r;
use crate::{r, r_expect};

#[test]
fn function_param_promises() {
Expand Down Expand Up @@ -191,4 +191,12 @@ mod test {
r! { quote(3 + 4) }
);
}

#[test]
fn literals_evaluate_to_themselves() {
r_expect!(substitute(1) == 1);
r_expect!(substitute("a") == "a");
r_expect!(substitute(true) == true);
r_expect!(substitute(1L) == 1L);
}
}
6 changes: 0 additions & 6 deletions src/context/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ pub trait Context: std::fmt::Debug + std::fmt::Display {
}
(k, v) => {
Ok(List::from(vec![(k, Obj::Promise(None, v, self.env()))]).iter_pairs())
// let k = k.map_or(OptionNA::NA, OptionNA::Some);
// if let Ok(elem) = self.eval(v) {
// Ok(List::from(vec![(k, elem)]).iter_pairs())
// } else {
// internal_err!()
// }
}
})
.collect::<Result<Vec<_>, _>>()?
Expand Down

0 comments on commit 951f5e9

Please sign in to comment.