Fix eval of negatives
This commit is contained in:
parent
fde169b623
commit
fa1544c71f
@ -529,6 +529,12 @@ mod eval_tests {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn op_eval() {
|
||||||
|
test_in_fresh_env!("- 13", "-13");
|
||||||
|
test_in_fresh_env!("10 - 2", "8");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_eval() {
|
fn function_eval() {
|
||||||
test_in_fresh_env!("fn oi(x) { x + 1 }; oi(4)", "5");
|
test_in_fresh_env!("fn oi(x) { x + 1 }; oi(4)", "5");
|
||||||
|
@ -450,7 +450,7 @@ impl BinOp {
|
|||||||
|
|
||||||
impl PrefixOp {
|
impl PrefixOp {
|
||||||
fn reduce(&self, symbol_table: &SymbolTable, arg: &Box<Meta<Expression>>) -> Expr {
|
fn reduce(&self, symbol_table: &SymbolTable, arg: &Box<Meta<Expression>>) -> Expr {
|
||||||
match Builtin::from_str(self.sigil()).ok() {
|
match self.builtin {
|
||||||
Some(op) => {
|
Some(op) => {
|
||||||
let f = Box::new(Expr::Func(Func::BuiltIn(op)));
|
let f = Box::new(Expr::Func(Func::BuiltIn(op)));
|
||||||
Expr::Call { f, args: vec![arg.node().reduce(symbol_table)]}
|
Expr::Call { f, args: vec![arg.node().reduce(symbol_table)]}
|
||||||
|
Loading…
Reference in New Issue
Block a user