use pnc_engine::{parse, value::Value};
#[test]
fn over_copies_second() {
let mut stack = Vec::new();
parse::eval_line(&mut stack, "1 2 over").unwrap();
assert_eq!(
stack,
vec![
Value::Int(1.into()),
Value::Int(2.into()),
Value::Int(1.into())
]
);
}
#[test]
fn rot_rotates_three() {
let mut stack = Vec::new();
parse::eval_line(&mut stack, "1 2 3 rot").unwrap();
assert_eq!(
stack,
vec![
Value::Int(2.into()),
Value::Int(3.into()),
Value::Int(1.into())
]
);
}
#[test]
fn to_rational_converts_int() {
let mut stack = Vec::new();
parse::eval_line(&mut stack, "5 to_rational").unwrap();
assert_eq!(
stack,
vec![Value::Rational(num_rational::BigRational::new(
5.into(),
1.into()
))]
);
}
#[test]
fn to_int_truncates() {
let mut stack = Vec::new();
parse::eval_line(&mut stack, "7 2 / to_int").unwrap();
assert_eq!(stack, vec![Value::Int(3.into())]);
}