stage2: add new test case

This commit is contained in:
Andrew Kelley 2020-07-13 00:31:55 -07:00
parent 08154c0deb
commit c94652a2fd

View File

@ -120,7 +120,7 @@ pub fn addCases(ctx: *TestContext) !void {
} }
{ {
var case = ctx.exe("adding numbers", linux_x64); var case = ctx.exe("adding numbers at comptime", linux_x64);
case.addCompareOutput( case.addCompareOutput(
\\export fn _start() noreturn { \\export fn _start() noreturn {
\\ asm volatile ("syscall" \\ asm volatile ("syscall"
@ -143,4 +143,31 @@ pub fn addCases(ctx: *TestContext) !void {
"Hello, World!\n", "Hello, World!\n",
); );
} }
{
var case = ctx.exe("adding numbers at runtime", linux_x64);
case.addCompareOutput(
\\export fn _start() noreturn {
\\ add(3, 4);
\\
\\ exit();
\\}
\\
\\fn add(a: u32, b: u32) void {
\\ if (a + b != 7) unreachable;
\\}
\\
\\fn exit() noreturn {
\\ asm volatile ("syscall"
\\ :
\\ : [number] "{rax}" (231),
\\ [arg1] "{rdi}" (0)
\\ : "rcx", "r11", "memory"
\\ );
\\ unreachable;
\\}
,
"",
);
}
} }