Skip to content

Commit

Permalink
add byte ops tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bernsteining committed Nov 16, 2023
1 parent d10dbb5 commit 4072b0a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions crates/rune/src/tests/vm_arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,44 @@ fn test_rem() {
error_test!(10 % 0 = DivideByZero);
}

#[test]
fn test_byte_ops() {
let out: u8 = rune!(
pub fn main() {
12u8 & 6u8
}
);
assert_eq!(out, 4u8);

let out: u8 = rune!(
pub fn main() {
12u8 ^ 6u8
}
);
assert_eq!(out, 10u8);

let out: u8 = rune!(
pub fn main() {
12u8 | 6u8
}
);
assert_eq!(out, 14u8);

let out: u8 = rune!(
pub fn main() {
12u8 << 2
}
);
assert_eq!(out, 48u8);

let out: u8 = rune!(
pub fn main() {
12u8 >> 2
}
);
assert_eq!(out, 3u8);
}

#[test]
fn test_bit_ops() {
op_tests!(0b1100 & 0b0110 = 0b1100 & 0b0110);
Expand Down

0 comments on commit 4072b0a

Please sign in to comment.