aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-02-13 12:50:13 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-02-13 12:50:13 -0700
commitc8376af92d63d13574cae7d177b7d314dda44cfe (patch)
tree2695432da4ce275d6b1555855bc05e2ceb4c3bc1 /test
parenta5aeb7381f22a42a8f11523267541243bab5964d (diff)
downloadzig-c8376af92d63d13574cae7d177b7d314dda44cfe.tar.gz
zig-c8376af92d63d13574cae7d177b7d314dda44cfe.zip
add @ctz, @clz and compiler_rt implementation
Diffstat (limited to 'test')
-rw-r--r--test/self_hosted.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/self_hosted.zig b/test/self_hosted.zig
index a35b2a5ff5..38338cfaf0 100644
--- a/test/self_hosted.zig
+++ b/test/self_hosted.zig
@@ -479,6 +479,20 @@ struct ArrayDotLenConstExpr {
const some_array = []u8 {0, 1, 2, 3};
+#attribute("test")
+fn count_leading_zeroes() {
+ assert(@clz(u8, 0b00001010) == 4);
+ assert(@clz(u8, 0b10001010) == 0);
+ assert(@clz(u8, 0b00000000) == 8);
+}
+
+#attribute("test")
+fn count_trailing_zeroes() {
+ assert(@ctz(u8, 0b10100000) == 5);
+ assert(@ctz(u8, 0b10001010) == 1);
+ assert(@ctz(u8, 0b00000000) == 8);
+}
+
fn assert(b: bool) {