| author | |
| committer | |
| log | 5e88a7a42724d7ccf9db58e1524beedebb1efd93 |
| tree | 6866e272f3f9e6511e9f1b8bb7f507138db4adb8 |
| parent | 06c08e5219f03328f483cded319c7ba75efb5188 |
| signature |
5 files changed, 28 insertions(+), 0 deletions(-)
CONTRIBUTING.md+5| ... | @@ -152,6 +152,11 @@ The relevant tests for this feature are: | ... | @@ -152,6 +152,11 @@ The relevant tests for this feature are: |
| 152 | same, and that the program exits cleanly. This kind of test coverage is preferred, when | 152 | same, and that the program exits cleanly. This kind of test coverage is preferred, when |
| 153 | possible, because it makes sure that the resulting Zig code is actually viable. | 153 | possible, because it makes sure that the resulting Zig code is actually viable. |
| 154 | 154 | ||
| 155 | * `test/stage1/behavior/translate_c_macros.zig` - each test case consists of a Zig test | ||
| 156 | which checks that the relevant macros in `test/stage1/behavior/translate_c_macros.h`. | ||
| 157 | have the correct values. Macros have to be tested separately since they are expanded by | ||
| 158 | Clang in `run_translated_c` tests. | ||
| 159 | |||
| 155 | * `test/translate_c.zig` - each test case is C code, with a list of expected strings which | 160 | * `test/translate_c.zig` - each test case is C code, with a list of expected strings which |
| 156 | must be found in the resulting Zig code. This kind of test is more precise in what it | 161 | must be found in the resulting Zig code. This kind of test is more precise in what it |
| 157 | measures, but does not provide test coverage of whether the resulting Zig code is valid. | 162 | measures, but does not provide test coverage of whether the resulting Zig code is valid. |
test/stage1/behavior.zig+1| ... | @@ -133,4 +133,5 @@ comptime { | ... | @@ -133,4 +133,5 @@ comptime { |
| 133 | _ = @import("behavior/while.zig"); | 133 | _ = @import("behavior/while.zig"); |
| 134 | _ = @import("behavior/widening.zig"); | 134 | _ = @import("behavior/widening.zig"); |
| 135 | _ = @import("behavior/src.zig"); | 135 | _ = @import("behavior/src.zig"); |
| 136 | _ = @import("behavior/translate_c_macros.zig"); | ||
| 136 | } | 137 | } |
test/stage1/behavior/translate_c_macros.h created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | // initializer list expression | ||
| 2 | typedef struct Color { | ||
| 3 | unsigned char r; | ||
| 4 | unsigned char g; | ||
| 5 | unsigned char b; | ||
| 6 | unsigned char a; | ||
| 7 | } Color; | ||
| 8 | #define CLITERAL(type) (type) | ||
| 9 | #define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 } // Light Gray | ||
| \ No newline at end of file | |||
test/stage1/behavior/translate_c_macros.zig created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | const expect = @import("std").testing.expect; | ||
| 2 | |||
| 3 | const h = @cImport(@cInclude("stage1/behavior/translate_c_macros.h")); | ||
| 4 | |||
| 5 | test "initializer list expression" { | ||
| 6 | @import("std").testing.expectEqual(h.Color{ | ||
| 7 | .r = 200, | ||
| 8 | .g = 200, | ||
| 9 | .b = 200, | ||
| 10 | .a = 255, | ||
| 11 | }, h.LIGHTGRAY); | ||
| 12 | } | ||
test/tests.zig+1| ... | @@ -537,6 +537,7 @@ pub fn addPkgTests( | ... | @@ -537,6 +537,7 @@ pub fn addPkgTests( |
| 537 | these_tests.enable_qemu = is_qemu_enabled; | 537 | these_tests.enable_qemu = is_qemu_enabled; |
| 538 | these_tests.enable_wasmtime = is_wasmtime_enabled; | 538 | these_tests.enable_wasmtime = is_wasmtime_enabled; |
| 539 | these_tests.glibc_multi_install_dir = glibc_dir; | 539 | these_tests.glibc_multi_install_dir = glibc_dir; |
| 540 | these_tests.addIncludeDir("test"); | ||
| 540 | 541 | ||
| 541 | step.dependOn(&these_tests.step); | 542 | step.dependOn(&these_tests.step); |
| 542 | } | 543 | } |