From 3902e49a7da5321c3c4d042bd5a26186989d3b65 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 23 Aug 2020 18:04:19 +0800 Subject: [PATCH] Fix bug in right-shifts. --- src/fn_call.rs | 2 +- tests/compound_equality.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fn_call.rs b/src/fn_call.rs index 4ac5a50d..f7836107 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -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)), _ => (), } diff --git a/tests/compound_equality.rs b/tests/compound_equality.rs index b09115a0..af5c16b6 100644 --- a/tests/compound_equality.rs +++ b/tests/compound_equality.rs @@ -45,16 +45,16 @@ fn test_divide_equals() -> Result<(), Box> { } #[test] -fn test_left_shift_equals() -> Result<(), Box> { +fn test_right_shift_equals() -> Result<(), Box> { let engine = Engine::new(); assert_eq!(engine.eval::("let x = 9; x >>=1; x")?, 4); Ok(()) } #[test] -fn test_right_shift_equals() -> Result<(), Box> { +fn test_left_shift_equals() -> Result<(), Box> { let engine = Engine::new(); - assert_eq!(engine.eval::("let x = 4; x<<= 2; x")?, 16); + assert_eq!(engine.eval::("let x = 4; x <<= 2; x")?, 16); Ok(()) }