From 64b2f06028702816839eec55a17ffe111adddd13 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 12 Aug 2021 14:42:57 -0500 Subject: [PATCH] added bucket_array test --- tests/bucket_array | 25 +++++++++++++++++++++++++ tests/bucket_array.onyx | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/bucket_array create mode 100644 tests/bucket_array.onyx diff --git a/tests/bucket_array b/tests/bucket_array new file mode 100644 index 00000000..0daca9e2 --- /dev/null +++ b/tests/bucket_array @@ -0,0 +1,25 @@ +[0] -> 0 +[1] -> 1 +[2] -> 2 +[3] -> 3 +[0] -> 4 +[1] -> 5 +[2] -> 6 +[3] -> 7 +[0] -> 8 +[1] -> 9 +[2] -> 10 +[3] -> 11 +[0] -> 12 +[1] -> 13 +[2] -> 14 +[3] -> 15 +[0] -> 16 +[1] -> 17 +[2] -> 18 +[3] -> 19 +[0] -> 20 +[1] -> 21 +[2] -> 22 +[3] -> 23 +Sum is 276 diff --git a/tests/bucket_array.onyx b/tests/bucket_array.onyx new file mode 100644 index 00000000..3ab81e30 --- /dev/null +++ b/tests/bucket_array.onyx @@ -0,0 +1,19 @@ +#load "core/std" + +use package core + +main :: (args: [] cstr) { + + ba := bucket_array.make(i32, 4); + for i: 24 { + bucket_array.push(^ba, i); + } + + sum := 0; + bucket_array.for_each(ba, #code { + printf("[{}] -> {}\n", bucket_index, *it); + sum += *it; + }); + + printf("Sum is {}\n", sum); +} \ No newline at end of file -- 2.25.1