feat: add bitwise left shift, right shift, and xor operand tests
Add comprehensive test files for bitwise lsh, rsh, and xor operations covering basic cases, max u32 boundary, past max u32 wrap, and operand type error checks for non-numeric right operands.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
IO.print(0 << 0) // expect: 0
|
||||
IO.print(1 << 0) // expect: 1
|
||||
IO.print(0 << 1) // expect: 0
|
||||
IO.print(1 << 1) // expect: 2
|
||||
IO.print(2863311530 << 1) // expect: 1431655764
|
||||
IO.print(4042322160 << 1) // expect: 3789677024
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 << 1) // expect: 4294967294
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 << 1) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
@@ -0,0 +1 @@
|
||||
1 << false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,15 @@
|
||||
IO.print(0 >> 0) // expect: 0
|
||||
IO.print(1 >> 0) // expect: 1
|
||||
IO.print(0 >> 1) // expect: 0
|
||||
IO.print(1 >> 1) // expect: 0
|
||||
IO.print(2863311530 >> 1) // expect: 1431655765
|
||||
IO.print(4042322160 >> 1) // expect: 2021161080
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 >> 1) // expect: 2147483647
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 >> 1) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
@@ -0,0 +1 @@
|
||||
1 >> false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,15 @@
|
||||
IO.print(0 ^ 0) // expect: 0
|
||||
IO.print(1 ^ 1) // expect: 0
|
||||
IO.print(0 ^ 1) // expect: 1
|
||||
IO.print(1 ^ 0) // expect: 1
|
||||
IO.print(2863311530 ^ 1431655765) // expect: 4294967295
|
||||
IO.print(4042322160 ^ 1010580540) // expect: 3435973836
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 ^ 4294967295) // expect: 0
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 ^ 4294967296) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
@@ -0,0 +1 @@
|
||||
1 ^ false // expect runtime error: Right operand must be a number.
|
||||
Reference in New Issue
Block a user