From c8bca94ca8bb727749eb3d44d5769a496b1ce55e Mon Sep 17 00:00:00 2001 From: Marvin Kaiser Date: Tue, 17 Dec 2019 16:47:00 +0100 Subject: [PATCH] Added tests that check that klang passes parameters to functions in the same way that gcc does it --- src/test/functionCall/functionCall.c | 12 +++++++++ src/test/functionCall/functionCall.h | 13 ++++++++- src/test/tests.k | 40 ++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/test/functionCall/functionCall.c b/src/test/functionCall/functionCall.c index b515c13..fc30112 100644 --- a/src/test/functionCall/functionCall.c +++ b/src/test/functionCall/functionCall.c @@ -22,6 +22,7 @@ int argumentTest(char* name, int expected, int result) { int runFunctionCallTests () { int failed = 0; printf("\nFunctionCallTests Tests \n"); + // Checks that parameters are correctly passed from gcc to functions failed += argumentTest("arg1", 1, arg1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); failed += argumentTest("arg2", 2, arg2(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); failed += argumentTest("arg3", 3, arg3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); @@ -32,5 +33,16 @@ int runFunctionCallTests () { failed += argumentTest("arg8", 8, arg8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); failed += argumentTest("arg9", 9, arg9(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); failed += argumentTest("arg10", 10, arg10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); + // Checks that parameters are correctly passed from klang to functions + failed += argumentTest("get1()", 1, get1()); + failed += argumentTest("get2()", 2, get2()); + failed += argumentTest("get3()", 3, get3()); + failed += argumentTest("get4()", 4, get4()); + failed += argumentTest("get5()", 5, get5()); + failed += argumentTest("get6()", 6, get6()); + failed += argumentTest("get7()", 7, get7()); + failed += argumentTest("get8()", 8, get8()); + failed += argumentTest("get9()", 9, get9()); + failed += argumentTest("get10()", 10, get10()); return failed; } \ No newline at end of file diff --git a/src/test/functionCall/functionCall.h b/src/test/functionCall/functionCall.h index 44846d5..56fbff7 100644 --- a/src/test/functionCall/functionCall.h +++ b/src/test/functionCall/functionCall.h @@ -7,4 +7,15 @@ int arg6(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j); int arg7(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j); int arg8(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j); int arg9(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j); -int arg10(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j); \ No newline at end of file +int arg10(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j); + +int get1(); +int get2(); +int get3(); +int get4(); +int get5(); +int get6(); +int get7(); +int get8(); +int get9(); +int get10(); \ No newline at end of file diff --git a/src/test/tests.k b/src/test/tests.k index 92e1bfa..f23c084 100644 --- a/src/test/tests.k +++ b/src/test/tests.k @@ -26,33 +26,73 @@ function arg1(a, b, c, d, e, f, g, h, i ,j) { return a; } +function get1() { + return arg1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg2(a, b, c, d, e, f, g, h, i ,j) { return b; } +function get2() { + return arg2(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg3(a, b, c, d, e, f, g, h, i ,j) { return c; } + +function get3() { + return arg3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg4(a, b, c, d, e, f, g, h, i ,j) { return d; } +function get4() { + return arg4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg5(a, b, c, d, e, f, g, h, i ,j) { return e; } +function get5() { + return arg5(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg6(a, b, c, d, e, f, g, h, i ,j) { return f; } +function get6() { + return arg6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg7(a, b, c, d, e, f, g, h, i ,j) { return g; } +function get7() { + return arg7(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg8(a, b, c, d, e, f, g, h, i ,j) { return h; } +function get8() { + return arg8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg9(a, b, c, d, e, f, g, h, i ,j) { return i; } +function get9() { + return arg9(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} + function arg10(a, b, c, d, e, f, g, h, i ,j) { return j; } +function get10() { + return arg10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +} add(1, 1);