Merge pull request #6660 from Vexu/stage2

Stage2 switch and package imports
This commit is contained in:
Veikka Tuominen
2020-10-31 09:39:28 +02:00
committed by GitHub
14 changed files with 1379 additions and 30 deletions

View File

@@ -974,6 +974,43 @@ pub fn addCases(ctx: *TestContext) !void {
,
"hello\nhello\nhello\nhello\nhello\n",
);
// comptime switch
// Basic for loop
case.addCompareOutput(
\\pub export fn _start() noreturn {
\\ assert(foo() == 1);
\\ exit();
\\}
\\
\\fn foo() u32 {
\\ const a: comptime_int = 1;
\\ var b: u32 = 0;
\\ switch (a) {
\\ 1 => b = 1,
\\ 2 => b = 2,
\\ else => unreachable,
\\ }
\\ return b;
\\}
\\
\\pub fn assert(ok: bool) void {
\\ if (!ok) unreachable; // assertion failure
\\}
\\
\\fn exit() noreturn {
\\ asm volatile ("syscall"
\\ :
\\ : [number] "{rax}" (231),
\\ [arg1] "{rdi}" (0)
\\ : "rcx", "r11", "memory"
\\ );
\\ unreachable;
\\}
,
"",
);
}
{