DEV: Default test case for select expressions.

This commit is contained in:
Jeremy Wall 2019-07-10 18:26:02 -05:00
parent c1f84c4861
commit fa294a2188

View File

@ -16,7 +16,8 @@ use super::scope::Stack;
use super::Composite::{List, Tuple}; use super::Composite::{List, Tuple};
use super::Op::{ use super::Op::{
Add, Bang, Bind, Cp, DeRef, Div, Element, Equal, FCall, Field, Func, InitList, InitThunk, Add, Bang, Bind, Cp, DeRef, Div, Element, Equal, FCall, Field, Func, InitList, InitThunk,
InitTuple, Jump, JumpIfFalse, JumpIfTrue, Module, Mul, Noop, Return, SelectJump, Sub, Sym, Val, InitTuple, Jump, JumpIfFalse, JumpIfTrue, Module, Mul, Noop, Pop, Return, SelectJump, Sub, Sym,
Val,
}; };
use super::Primitive::{Bool, Float, Int, Str}; use super::Primitive::{Bool, Float, Int, Str};
use super::Value::{C, P}; use super::Value::{C, P};
@ -411,8 +412,22 @@ fn test_select_short_circuit() {
Sym("field".to_owned()), // 5 // second field to compare Sym("field".to_owned()), // 5 // second field to compare
SelectJump(2), // 6 SelectJump(2), // 6
Val(Int(1)), // 7 // expression for second field Val(Int(1)), // 7 // expression for second field
Jump(2), // 8
Pop, // 9 // pop the search field off
Bang, // 10 // default case
] => P(Int(1)),
vec![
Sym("field".to_owned()), // 0 // search field
Sym("not_field".to_owned()), // 1 // first field to compare
SelectJump(2), // 2
Val(Str("not our value".to_owned())), // 3 // expression for first field
Jump(4), // 4
Sym("als not field".to_owned()), // 5 // second field to compare
SelectJump(2), // 6
Val(Int(1)), // 7 // expression for second field
Jump(1), // 8 Jump(1), // 8
Bang, // 9 // default case Pop, // 9 // pop the search field off
Val(Int(1)), // 10 // default case
] => P(Int(1)), ] => P(Int(1)),
]; ];
} }