stage2: fix test cases to add pub on exported _start fn

This way the start code respects them.
This commit is contained in:
Andrew Kelley 2021-05-12 23:17:24 -07:00
parent c102e13710
commit b109daacdd
7 changed files with 64 additions and 64 deletions

View File

@ -11,7 +11,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("linux_aarch64 hello world", linux_aarch64);
// Regular old hello world
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print();
\\ exit();
\\}
@ -51,7 +51,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("exit fn taking argument", linux_aarch64);
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ exit(0);
\\}
\\

View File

@ -11,7 +11,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("linux_arm hello world", linux_arm);
// Regular old hello world
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print();
\\ exit();
\\}
@ -50,7 +50,7 @@ pub fn addCases(ctx: *TestContext) !void {
// be in a specific order because otherwise the write to r0
// would overwrite the len parameter which resides in r0
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print(id(14));
\\ exit();
\\}
@ -89,7 +89,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("non-leaf functions", linux_arm);
// Testing non-leaf functions
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ foo();
\\ exit();
\\}
@ -119,7 +119,7 @@ pub fn addCases(ctx: *TestContext) !void {
// Add two numbers
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print(2, 4);
\\ print(1, 7);
\\ exit();
@ -152,7 +152,7 @@ pub fn addCases(ctx: *TestContext) !void {
// Subtract two numbers
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print(10, 5);
\\ print(4, 3);
\\ exit();
@ -185,7 +185,7 @@ pub fn addCases(ctx: *TestContext) !void {
// Bitwise And
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print(8, 9);
\\ print(3, 7);
\\ exit();
@ -218,7 +218,7 @@ pub fn addCases(ctx: *TestContext) !void {
// Bitwise Or
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print(4, 2);
\\ print(3, 7);
\\ exit();
@ -251,7 +251,7 @@ pub fn addCases(ctx: *TestContext) !void {
// Bitwise Xor
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print(42, 42);
\\ print(3, 5);
\\ exit();
@ -287,7 +287,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("if statements", linux_arm);
// Simple if statement in assert
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ var x: u32 = 123;
\\ var y: u32 = 42;
\\ assert(x > y);
@ -316,7 +316,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("while loops", linux_arm);
// Simple while loop with assert
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ var x: u32 = 2020;
\\ var i: u32 = 0;
\\ while (x > 0) {
@ -349,7 +349,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("integer multiplication", linux_arm);
// Simple u32 integer multiplication
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ assert(mul(1, 1) == 1);
\\ assert(mul(42, 1) == 42);
\\ assert(mul(1, 42) == 42);
@ -385,7 +385,7 @@ pub fn addCases(ctx: *TestContext) !void {
// callee preserved register, otherwise it will be overwritten
// by the first parameter to baz.
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ assert(foo() == 43);
\\ exit();
\\}
@ -423,7 +423,7 @@ pub fn addCases(ctx: *TestContext) !void {
{
var case = ctx.exe("recursive fibonacci", linux_arm);
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ assert(fib(0) == 0);
\\ assert(fib(1) == 1);
\\ assert(fib(2) == 1);
@ -462,7 +462,7 @@ pub fn addCases(ctx: *TestContext) !void {
{
var case = ctx.exe("spilling registers", linux_arm);
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ assert(add(3, 4) == 791);
\\ exit();
\\}

View File

@ -17,7 +17,7 @@ pub fn addCases(ctx: *TestContext) !void {
// Incorrect return type
case.addError(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\}
, &[_][]const u8{":2:1: error: expected noreturn, found void"});
@ -26,7 +26,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\extern "c" fn write(usize, usize, usize) usize;
\\extern "c" fn exit(usize) noreturn;
\\
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print();
\\
\\ exit(0);
@ -46,7 +46,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\extern "c" fn write(usize, usize, usize) usize;
\\extern "c" fn exit(usize) noreturn;
\\
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print();
\\
\\ exit(0);
@ -66,7 +66,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\extern "c" fn write(usize, usize, usize) usize;
\\extern "c" fn exit(usize) noreturn;
\\
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print();
\\ print();
\\
@ -92,7 +92,7 @@ pub fn addCases(ctx: *TestContext) !void {
case.addCompareOutput(
\\extern "c" fn exit(usize) noreturn;
\\
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ exit(0);
\\}
,
@ -103,7 +103,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\extern "c" fn exit(usize) noreturn;
\\extern "c" fn write(usize, usize, usize) usize;
\\
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ _ = write(1, @ptrToInt("Hey!\n"), 5);
\\ exit(0);
\\}

View File

@ -18,7 +18,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ return a + b;
\\}
\\
\\export fn main() c_int {
\\pub export fn main() c_int {
\\ var a: i32 = -5;
\\ const x = add(a, 7);
\\ var y = add(2, 0);
@ -34,7 +34,7 @@ pub fn addCases(ctx: *TestContext) !void {
case.addCompareOutput(
\\extern fn puts(s: [*:0]const u8) c_int;
\\
\\export fn main() c_int {
\\pub export fn main() c_int {
\\ _ = puts("hello world!");
\\ return 0;
\\}
@ -53,7 +53,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ if (!ok) unreachable;
\\}
\\
\\export fn main() c_int {
\\pub export fn main() c_int {
\\ assert(add(1,2) == 3);
\\ return 0;
\\}
@ -77,7 +77,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ return val + 10;
\\}
\\
\\export fn main() c_int {
\\pub export fn main() c_int {
\\ assert(foo(false) == 20);
\\ assert(foo(true) == 30);
\\ return 0;
@ -104,7 +104,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ return val;
\\}
\\
\\export fn main() c_int {
\\pub export fn main() c_int {
\\ assert(foo(false) == 10);
\\ assert(foo(true) == 20);
\\ return 0;
@ -120,7 +120,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ if (!ok) unreachable;
\\}
\\
\\export fn main() c_int {
\\pub export fn main() c_int {
\\ var sum: u32 = 0;
\\ var i: u32 = 0;
\\ while (i < 5) : (i += 1) {
@ -141,7 +141,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ if (!ok) unreachable;
\\}
\\
\\export fn main() c_int {
\\pub export fn main() c_int {
\\ var opt_val: ?i32 = 10;
\\ var null_val: ?i32 = null;
\\
@ -190,7 +190,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ if (!ok) unreachable;
\\}
\\
\\export fn main() c_int {
\\pub export fn main() c_int {
\\ var x: u32 = 0;
\\ for ("hello") |_| {
\\ x += 1;

View File

@ -11,7 +11,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("riscv64 hello world", linux_riscv64);
// Regular old hello world
case.addCompareOutput(
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ print();
\\
\\ exit();

View File

@ -15,7 +15,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ unreachable;
\\}
\\
\\export fn _start() noreturn {
\\pub export fn _start() noreturn {
\\ killEmulator();
\\}
, "");

View File

@ -11,7 +11,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("wasm function calls", wasi);
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ foo();
\\ bar();
\\ return 42;
@ -26,7 +26,7 @@ pub fn addCases(ctx: *TestContext) !void {
);
case.addCompareOutput(
\\export fn _start() i64 {
\\pub export fn _start() i64 {
\\ bar();
\\ foo();
\\ foo();
@ -44,7 +44,7 @@ pub fn addCases(ctx: *TestContext) !void {
);
case.addCompareOutput(
\\export fn _start() f32 {
\\pub export fn _start() f32 {
\\ bar();
\\ foo();
\\ return 42.0;
@ -66,7 +66,7 @@ pub fn addCases(ctx: *TestContext) !void {
);
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ foo(10, 20);
\\ return 5;
\\}
@ -78,7 +78,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("wasm locals", wasi);
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ var y: f32 = 42.0;
\\ var x: u32 = 10;
@ -87,7 +87,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "5\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ var y: f32 = 42.0;
\\ var x: u32 = 10;
@ -106,7 +106,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("wasm binary operands", wasi);
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ i += 20;
\\ return i;
@ -114,7 +114,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "25\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ i += 20;
\\ var result: u32 = foo(i, 10);
@ -126,7 +126,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "35\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 20;
\\ i -= 5;
\\ return i;
@ -134,7 +134,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "15\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ i -= 3;
\\ var result: u32 = foo(i, 10);
@ -146,7 +146,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "8\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ i *= 7;
\\ var result: u32 = foo(i, 10);
@ -158,7 +158,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "350\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 352;
\\ i /= 7; // i = 50
\\ var result: u32 = foo(i, 7);
@ -170,7 +170,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "7\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ i &= 6;
\\ return i;
@ -178,7 +178,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "4\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ i |= 6;
\\ return i;
@ -186,7 +186,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "7\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ i ^= 6;
\\ return i;
@ -194,7 +194,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "3\n");
case.addCompareOutput(
\\export fn _start() bool {
\\pub export fn _start() bool {
\\ var b: bool = false;
\\ b = b or false;
\\ return b;
@ -202,7 +202,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "0\n");
case.addCompareOutput(
\\export fn _start() bool {
\\pub export fn _start() bool {
\\ var b: bool = true;
\\ b = b or false;
\\ return b;
@ -210,7 +210,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "1\n");
case.addCompareOutput(
\\export fn _start() bool {
\\pub export fn _start() bool {
\\ var b: bool = false;
\\ b = b or true;
\\ return b;
@ -218,7 +218,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "1\n");
case.addCompareOutput(
\\export fn _start() bool {
\\pub export fn _start() bool {
\\ var b: bool = true;
\\ b = b or true;
\\ return b;
@ -226,7 +226,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "1\n");
case.addCompareOutput(
\\export fn _start() bool {
\\pub export fn _start() bool {
\\ var b: bool = false;
\\ b = b and false;
\\ return b;
@ -234,7 +234,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "0\n");
case.addCompareOutput(
\\export fn _start() bool {
\\pub export fn _start() bool {
\\ var b: bool = true;
\\ b = b and false;
\\ return b;
@ -242,7 +242,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "0\n");
case.addCompareOutput(
\\export fn _start() bool {
\\pub export fn _start() bool {
\\ var b: bool = false;
\\ b = b and true;
\\ return b;
@ -250,7 +250,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "0\n");
case.addCompareOutput(
\\export fn _start() bool {
\\pub export fn _start() bool {
\\ var b: bool = true;
\\ b = b and true;
\\ return b;
@ -262,7 +262,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("wasm conditions", wasi);
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ if (i > @as(u32, 4)) {
\\ i += 10;
@ -272,7 +272,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "15\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ if (i < @as(u32, 4)) {
\\ i += 10;
@ -284,7 +284,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "2\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 5;
\\ if (i < @as(u32, 4)) {
\\ i += 10;
@ -296,7 +296,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "20\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 11;
\\ if (i < @as(u32, 4)) {
\\ i += 10;
@ -312,7 +312,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "31\n");
case.addCompareOutput(
\\export fn _start() void {
\\pub export fn _start() void {
\\ assert(foo(true) != @as(i32, 30));
\\}
\\
@ -327,7 +327,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "");
case.addCompareOutput(
\\export fn _start() void {
\\pub export fn _start() void {
\\ assert(foo(false) == @as(i32, 20));
\\ assert(foo(true) == @as(i32, 30));
\\}
@ -351,7 +351,7 @@ pub fn addCases(ctx: *TestContext) !void {
var case = ctx.exe("wasm while loops", wasi);
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 0;
\\ while(i < @as(u32, 5)){
\\ i += 1;
@ -362,7 +362,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "5\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 0;
\\ while(i < @as(u32, 10)){
\\ var x: u32 = 1;
@ -373,7 +373,7 @@ pub fn addCases(ctx: *TestContext) !void {
, "10\n");
case.addCompareOutput(
\\export fn _start() u32 {
\\pub export fn _start() u32 {
\\ var i: u32 = 0;
\\ while(i < @as(u32, 10)){
\\ var x: u32 = 1;