From 50d54b9d05d87fe03f10b022b48dad7cec0ca8c3 Mon Sep 17 00:00:00 2001 From: Daniel_Cortez Date: Sun, 15 Sep 2019 20:51:16 +0700 Subject: [PATCH] Add tests --- source/compiler/tests/__addressof.meta | 9 +++++ source/compiler/tests/__addressof.pwn | 52 ++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 source/compiler/tests/__addressof.meta create mode 100644 source/compiler/tests/__addressof.pwn diff --git a/source/compiler/tests/__addressof.meta b/source/compiler/tests/__addressof.meta new file mode 100644 index 0000000..fe4d61b --- /dev/null +++ b/source/compiler/tests/__addressof.meta @@ -0,0 +1,9 @@ +{ + 'test_type': 'output_check', + 'errors': """ +__addressof.pwn(3) : error 017: undefined symbol "Func1" +__addressof.pwn(16) : error 093: "__addressof" operator is invalid in preprocessor expressions +__addressof.pwn(21) : error 001: expected token: "-variable, array, array cell, label or function-", but found "-numeric value-" +__addressof.pwn(24) : error 001: expected token: "-variable, array, array cell, label or function-", but found "-native function-" + """ +} diff --git a/source/compiler/tests/__addressof.pwn b/source/compiler/tests/__addressof.pwn new file mode 100644 index 0000000..f7a6141 --- /dev/null +++ b/source/compiler/tests/__addressof.pwn @@ -0,0 +1,52 @@ +#include + +const func1_addr = __addressof(Func1); // error + +Func1() {} +Func2() {} +Func3() {} + +new const functions[3] = +{ + __addressof(Func1), + __addressof(Func2), + __addressof(Func3) +}; + +#if __addressof Func1 > 0 // error +#endif + +main() +{ + const a = __addressof func1_addr; // error + #pragma unused a + + const b = __addressof printf; // error + #pragma unused b + +lbl: + const c = __addressof lbl; + #pragma unused c + + const d = __addressof functions; + #pragma unused d + + const e = __addressof functions[1]; + #pragma unused e + + static x = 0; + const f = __addressof x; + #pragma unused f + + static arr1[3][2] = { { 0, ... }, ... }; + const g = __addressof arr1[2][1]; + #pragma unused g + + new y = 0; + new const h = __addressof y; + #pragma unused h + + new arr2[3][2] = { { 0, ... }, ... }; + new const i = __addressof arr2; + #pragma unused i +}