Added tests that check that klang passes parameters to functions in the same way that gcc does it

This commit is contained in:
Marvin Kaiser
2019-12-17 16:47:00 +01:00
parent d3847682d6
commit c8bca94ca8
3 changed files with 64 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ int argumentTest(char* name, int expected, int result) {
int runFunctionCallTests () { int runFunctionCallTests () {
int failed = 0; int failed = 0;
printf("\nFunctionCallTests Tests \n"); 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("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("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)); 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("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("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)); 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; return failed;
} }

View File

@@ -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 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 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 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); 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();

View File

@@ -26,33 +26,73 @@ function arg1(a, b, c, d, e, f, g, h, i ,j) {
return a; 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) { function arg2(a, b, c, d, e, f, g, h, i ,j) {
return b; 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) { function arg3(a, b, c, d, e, f, g, h, i ,j) {
return c; 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) { function arg4(a, b, c, d, e, f, g, h, i ,j) {
return d; 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) { function arg5(a, b, c, d, e, f, g, h, i ,j) {
return e; 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) { function arg6(a, b, c, d, e, f, g, h, i ,j) {
return f; 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) { function arg7(a, b, c, d, e, f, g, h, i ,j) {
return g; 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) { function arg8(a, b, c, d, e, f, g, h, i ,j) {
return h; 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) { function arg9(a, b, c, d, e, f, g, h, i ,j) {
return i; 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) { function arg10(a, b, c, d, e, f, g, h, i ,j) {
return j; return j;
} }
function get10() {
return arg10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}
add(1, 1); add(1, 1);