stage2: add block test cases llvm backend

This commit is contained in:
Timon Kruiper 2021-03-24 15:41:32 +01:00 committed by Andrew Kelley
parent 522707622e
commit ea42ab34ab

View File

@ -60,57 +60,57 @@ pub fn addCases(ctx: *TestContext) !void {
, "");
}
//{
// var case = ctx.exeUsingLlvmBackend("blocks", linux_x64);
{
var case = ctx.exeUsingLlvmBackend("blocks", linux_x64);
// case.addCompareOutput(
// \\fn assert(ok: bool) void {
// \\ if (!ok) unreachable;
// \\}
// \\
// \\fn foo(ok: bool) i32 {
// \\ const val: i32 = blk: {
// \\ var x: i32 = 1;
// \\ if (!ok) break :blk x + 9;
// \\ break :blk x + 19;
// \\ };
// \\ return val + 10;
// \\}
// \\
// \\export fn main() c_int {
// \\ assert(foo(false) == 20);
// \\ assert(foo(true) == 30);
// \\ return 0;
// \\}
// , "");
//}
case.addCompareOutput(
\\fn assert(ok: bool) void {
\\ if (!ok) unreachable;
\\}
\\
\\fn foo(ok: bool) i32 {
\\ const val: i32 = blk: {
\\ var x: i32 = 1;
\\ if (!ok) break :blk x + 9;
\\ break :blk x + 19;
\\ };
\\ return val + 10;
\\}
\\
\\export fn main() c_int {
\\ assert(foo(false) == 20);
\\ assert(foo(true) == 30);
\\ return 0;
\\}
, "");
}
//{
// var case = ctx.exeUsingLlvmBackend("nested blocks", linux_x64);
{
var case = ctx.exeUsingLlvmBackend("nested blocks", linux_x64);
// case.addCompareOutput(
// \\fn assert(ok: bool) void {
// \\ if (!ok) unreachable;
// \\}
// \\
// \\fn foo(ok: bool) i32 {
// \\ var val: i32 = blk: {
// \\ const val2: i32 = another: {
// \\ if (!ok) break :blk 10;
// \\ break :another 10;
// \\ };
// \\ break :blk val2 + 10;
// \\ };
// \\ return val;
// \\}
// \\
// \\export fn main() c_int {
// \\ assert(foo(false) == 10);
// \\ assert(foo(true) == 20);
// \\ return 0;
// \\}
// , "");
//}
case.addCompareOutput(
\\fn assert(ok: bool) void {
\\ if (!ok) unreachable;
\\}
\\
\\fn foo(ok: bool) i32 {
\\ var val: i32 = blk: {
\\ const val2: i32 = another: {
\\ if (!ok) break :blk 10;
\\ break :another 10;
\\ };
\\ break :blk val2 + 10;
\\ };
\\ return val;
\\}
\\
\\export fn main() c_int {
\\ assert(foo(false) == 10);
\\ assert(foo(true) == 20);
\\ return 0;
\\}
, "");
}
{
var case = ctx.exeUsingLlvmBackend("while loops", linux_x64);