| ... | ... | @@ -169,8 +169,38 @@ pub fn addCases(ctx: *TestContext) !void { |
| 169 | 169 | , |
| 170 | 170 | "", |
| 171 | 171 | ); |
| 172 | } |
| 172 | 173 | |
| 173 | | // Tests the assert() function. |
| 174 | { |
| 175 | // TODO add a test case for comptime substraction of numbers |
| 176 | var case = ctx.exe("substracting numbers at runtime", linux_x64); |
| 177 | case.addCompareOutput( |
| 178 | \\export fn _start() noreturn { |
| 179 | \\ sub(7, 8); |
| 180 | \\ |
| 181 | \\ exit(); |
| 182 | \\} |
| 183 | \\ |
| 184 | \\fn sub(a: u32, b: u32) void { |
| 185 | \\ if (a - b != 3) unreachable; |
| 186 | \\} |
| 187 | \\ |
| 188 | \\fn exit() noreturn { |
| 189 | \\ asm volatile ("syscall" |
| 190 | \\ : |
| 191 | \\ : [number] "{rax}" (231), |
| 192 | \\ [arg1] "{rdi}" (0) |
| 193 | \\ : "rcx", "r11", "memory" |
| 194 | \\ ); |
| 195 | \\ unreachable; |
| 196 | \\} |
| 197 | , |
| 198 | "", |
| 199 | ); |
| 200 | } |
| 201 | |
| 202 | { |
| 203 | var case = ctx.exe("assert function", linux_x64); |
| 174 | 204 | case.addCompareOutput( |
| 175 | 205 | \\export fn _start() noreturn { |
| 176 | 206 | \\ add(3, 4); |