瀏覽代碼

[hlc] Add tests for hl header macro clashes (#810)

tobil4sk 1 月之前
父節點
當前提交
08d06712a9
共有 3 個文件被更改,包括 154 次插入0 次删除
  1. 14 0
      CMakeLists.txt
  2. 114 0
      other/tests/header_macro_clashes/check.h
  3. 26 0
      other/tests/header_macro_clashes/header_macro_clashes.c

+ 14 - 0
CMakeLists.txt

@@ -324,6 +324,20 @@ if(BUILD_TESTING)
         uv.hdll
     )
 
+    #####################
+    # header_macro_clashes.c
+
+    add_executable(header_macro_clashes
+        ${CMAKE_SOURCE_DIR}/other/tests/header_macro_clashes/header_macro_clashes.c
+    )
+    set_target_properties(header_macro_clashes
+        PROPERTIES
+        RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test/
+    )
+    target_link_libraries(header_macro_clashes
+        libhl
+    )
+
     #####################
     # Tests
     if (WITH_VM)

+ 114 - 0
other/tests/header_macro_clashes/check.h

@@ -0,0 +1,114 @@
+#ifdef CONST
+#error "CONST is defined"
+#endif
+#ifdef IN
+#error "IN is defined"
+#endif
+#ifdef OUT
+#error "OUT is defined"
+#endif
+#ifdef OPTIONAL
+#error "OPTIONAL is defined"
+#endif
+#ifdef stdin
+#error "stdin is defined"
+#endif
+#ifdef stdout
+#error "stdout is defined"
+#endif
+#ifdef stderr
+#error "stderr is defined"
+#endif
+#ifdef DELETE
+#error "DELETE is defined"
+#endif
+#ifdef ERROR
+#error "ERROR is defined"
+#endif
+#ifdef NO_ERROR
+#error "NO_ERROR is defined"
+#endif
+#ifdef EOF
+#error "EOF is defined"
+#endif
+#ifdef STRICT
+#error "STRICT is defined"
+#endif
+#ifdef TRUE
+#error "TRUE is defined"
+#endif
+#ifdef FALSE
+#error "FALSE is defined"
+#endif
+#ifdef CW_USEDEFAULT
+#error "CW_USEDEFAULT is defined"
+#endif
+#ifdef HIDDEN
+#error "HIDDEN is defined"
+#endif
+#ifdef RESIZABLE
+#error "RESIZABLE is defined"
+#endif
+#ifdef __SIGN
+#error "__SIGN is defined"
+#endif
+#ifdef far
+#error "far is defined"
+#endif
+#ifdef FAR
+#error "FAR is defined"
+#endif
+#ifdef near
+#error "near is defined"
+#endif
+#ifdef NEAR
+#error "NEAR is defined"
+#endif
+#ifdef GENERIC_READ
+#error "GENERIC_READ is defined"
+#endif
+#ifdef INT_MAX
+#error "INT_MAX is defined"
+#endif
+#ifdef INT_MIN
+#error "INT_MIN is defined"
+#endif
+#ifdef BIG_ENDIAN
+#error "BIG_ENDIAN is defined"
+#endif
+#ifdef LITTLE_ENDIAN
+#error "LITTLE_ENDIAN is defined"
+#endif
+#ifdef ALTERNATE
+#error "ALTERNATE is defined"
+#endif
+#ifdef DIFFERENCE
+#error "DIFFERENCE is defined"
+#endif
+#ifdef DOUBLE_CLICK
+#error "DOUBLE_CLICK is defined"
+#endif
+#ifdef WAIT_FAILED
+#error "WAIT_FAILED is defined"
+#endif
+#ifdef OVERFLOW
+#error "OVERFLOW is defined"
+#endif
+#ifdef UNDERFLOW
+#error "UNDERFLOW is defined"
+#endif
+#ifdef DOMAIN
+#error "DOMAIN is defined"
+#endif
+#ifdef TRANSPARENT
+#error "TRANSPARENT is defined"
+#endif
+#ifdef CopyFile
+#error "CopyFile is defined"
+#endif
+#ifdef COLOR_HIGHLIGHT
+#error "COLOR_HIGHLIGHT is defined"
+#endif
+#ifdef __valid
+#error "__valid is defined"
+#endif

+ 26 - 0
other/tests/header_macro_clashes/header_macro_clashes.c

@@ -0,0 +1,26 @@
+/*
+	We want to limit the amount of macros defined by including hl headers.
+*/
+
+#define HLC_BOOT /* Enables some undefs in hlc.h */
+
+#include <hl.h>
+#include <hlc.h>
+
+#include "check.h"
+
+/* check before and after including hlc_main.c */
+#include <hlc_main.c>
+
+#include "check.h"
+
+/* Required by hlc.h */
+void* hlc_static_call(void *fun, hl_type *t, void **args, vdynamic *out) {
+	return NULL;
+}
+
+void* hlc_get_wrapper( hl_type* type ) {
+	return NULL;
+}
+
+void hl_entry_point() {}