From 29c9210f8178941def73200f1947592befb71694 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sat, 26 Sep 2020 23:39:13 -0500 Subject: [PATCH] added vararg_test.onyx --- tests/vararg_test | 8 ++++++++ tests/vararg_test.onyx | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/vararg_test create mode 100644 tests/vararg_test.onyx diff --git a/tests/vararg_test b/tests/vararg_test new file mode 100644 index 00000000..dec9f7f1 --- /dev/null +++ b/tests/vararg_test @@ -0,0 +1,8 @@ +foo +1 +2 +1077936128 +1084227584 +bar +1 +Hello, 1234, World! diff --git a/tests/vararg_test.onyx b/tests/vararg_test.onyx new file mode 100644 index 00000000..87a414e9 --- /dev/null +++ b/tests/vararg_test.onyx @@ -0,0 +1,27 @@ +package main + +#include_file "core/std/js" + +use package core; + +old_va_test :: proc (prefix: string, va: ..i32) { + println(prefix); + for v: va do println(v); +} + +new_va_test :: proc (prefix: string, va: ...) { + println(prefix); + + for i: 0 .. va.count { + x : i32; + vararg_get(va, ^x); + println(x); + } +} + +main :: proc (args: [] cstring) { + new_va_test("foo", 1, 2, 3.0f, 5.0f); + old_va_test("bar", 1); + + printf("Hello, %i, %s!\n", 1234, "World"); +} -- 2.25.1