added bucket_array test
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 12 Aug 2021 19:42:57 +0000 (14:42 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 12 Aug 2021 19:42:57 +0000 (14:42 -0500)
tests/bucket_array [new file with mode: 0644]
tests/bucket_array.onyx [new file with mode: 0644]

diff --git a/tests/bucket_array b/tests/bucket_array
new file mode 100644 (file)
index 0000000..0daca9e
--- /dev/null
@@ -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 (file)
index 0000000..3ab81e3
--- /dev/null
@@ -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