Fix bug in right-shifts.

This commit is contained in:
Stephen Chung 2020-08-23 18:04:19 +08:00
parent a72f797da1
commit 3902e49a7d
2 changed files with 4 additions and 4 deletions

View File

@ -1280,7 +1280,7 @@ pub fn run_builtin_op_assignment(
"/=" => return Ok(Some(*x /= y)),
"%=" => return Ok(Some(*x %= y)),
"~=" => return Ok(Some(*x = x.pow(y as u32))),
">>=" => return Ok(Some(*x = *x << y)),
">>=" => return Ok(Some(*x = *x >> y)),
"<<=" => return Ok(Some(*x = *x << y)),
_ => (),
}

View File

@ -45,16 +45,16 @@ fn test_divide_equals() -> Result<(), Box<EvalAltResult>> {
}
#[test]
fn test_left_shift_equals() -> Result<(), Box<EvalAltResult>> {
fn test_right_shift_equals() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
assert_eq!(engine.eval::<INT>("let x = 9; x >>=1; x")?, 4);
Ok(())
}
#[test]
fn test_right_shift_equals() -> Result<(), Box<EvalAltResult>> {
fn test_left_shift_equals() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
assert_eq!(engine.eval::<INT>("let x = 4; x<<= 2; x")?, 16);
assert_eq!(engine.eval::<INT>("let x = 4; x <<= 2; x")?, 16);
Ok(())
}