Rename bitwise operators.

This commit is contained in:
Calvin Rose
2018-12-16 22:13:48 -05:00
parent 03dbd79165
commit 99e14a9b70
4 changed files with 22 additions and 28 deletions
+8 -8
View File
@@ -24,8 +24,8 @@
(assert (= 10 (+ 1 2 3 4)) "addition")
(assert (= -8 (- 1 2 3 4)) "subtraction")
(assert (= 24 (* 1 2 3 4)) "multiplication")
(assert (= 4 (<< 1 2)) "left shift")
(assert (= 1 (>> 4 2)) "right shift")
(assert (= 4 (blshift 1 2)) "left shift")
(assert (= 1 (brshift 4 2)) "right shift")
(assert (< 1 2 3 4 5 6) "less than integers")
(assert (< 1.0 2.0 3.0 4.0 5.0 6.0) "less than reals")
(assert (> 6 5 4 3 2 1) "greater than integers")
@@ -60,10 +60,10 @@
(assert (not false) "false literal")
(assert true "true literal")
(assert (not nil) "nil literal")
(assert (= 7 (| 3 4)) "bit or")
(assert (= 0 (& 3 4)) "bit and")
(assert (= 0xFF (^ 0x0F 0xF0)) "bit xor")
(assert (= 0xF0 (^ 0xFF 0x0F)) "bit xor 2")
(assert (= 7 (bor 3 4)) "bit or")
(assert (= 0 (band 3 4)) "bit and")
(assert (= 0xFF (bxor 0x0F 0xF0)) "bit xor")
(assert (= 0xF0 (bxor 0xFF 0x0F)) "bit xor 2")
# Set global variables to prevent some possible compiler optimizations that defeat point of the test
(var zero 0)
@@ -127,14 +127,14 @@
(var accum 1)
(var count 0)
(while (< count 16)
(set accum (<< accum 1))
(set accum (blshift accum 1))
(set count (+ 1 count)))
(assert (= accum 65536) "loop in closure")))
(var accum 1)
(var count 0)
(while (< count 16)
(set accum (<< accum 1))
(set accum (blshift accum 1))
(set count (+ 1 count)))
(assert (= accum 65536) "loop globally")