summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/01_arithmetic/03_bitwise
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2021-03-19 16:54:55 +0100
committerJo-Philipp Wich <jo@mein.io>2021-04-23 00:42:30 +0200
commit2b59097c3f61fa901e91ac4cea48940760439578 (patch)
tree958d739a78f959dfcd55b3d76e6e970ca53fa1c6 /tests/custom/01_arithmetic/03_bitwise
parent80393611fb6634abcc0da1dee2da7c4418dbde8d (diff)
tests: create custom tests from current tests cases
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'tests/custom/01_arithmetic/03_bitwise')
-rw-r--r--tests/custom/01_arithmetic/03_bitwise54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/custom/01_arithmetic/03_bitwise b/tests/custom/01_arithmetic/03_bitwise
new file mode 100644
index 0000000..faf4ffd
--- /dev/null
+++ b/tests/custom/01_arithmetic/03_bitwise
@@ -0,0 +1,54 @@
+Utpl implements C-style bitwise operations. One detail is that these operations
+coerce their operands to signed 64bit integer values internally.
+
+-- Expect stdout --
+Left shift:
+10 << 2 = 40
+3.3 << 4.1 = 48
+
+Right shift:
+10 >> 2 = 2
+3.3 >> 4.1 = 0
+
+Bitwise and:
+1234 & 200 = 192
+120.3 & 54.3 = 48
+
+Bitwise xor:
+1234 ^ 200 = 1050
+120.3 ^ 54.3 = 78
+
+Bitwise or:
+1234 | 200 = 1242
+120.3 | 54.3 = 126
+
+Complement:
+~0 = -1
+~10.4 = -11
+-- End --
+
+-- Testcase --
+Left shift:
+10 << 2 = {{ 10 << 2 }}
+3.3 << 4.1 = {{ 3.3 << 4.1 }}
+
+Right shift:
+10 >> 2 = {{ 10 >> 2 }}
+3.3 >> 4.1 = {{ 3.3 >> 4.1 }}
+
+Bitwise and:
+1234 & 200 = {{ 1234 & 200 }}
+120.3 & 54.3 = {{ 120.3 & 54.3 }}
+
+Bitwise xor:
+1234 ^ 200 = {{ 1234 ^ 200 }}
+120.3 ^ 54.3 = {{ 120.3 ^ 54.3 }}
+
+Bitwise or:
+1234 | 200 = {{ 1234 | 200 }}
+120.3 | 54.3 = {{ 120.3 | 54.3 }}
+
+Complement:
+~0 = {{ ~0 }}
+~10.4 = {{ ~10.4 }}
+-- End --