authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-06-26 03:08:21-04:00
committergravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-06-26 03:09:56-04:00
log53fead580eb2abc2813d70b794239c4629324159
tree95b9c321bcaec05307358f3ac8ccd29e846a2389
parent649da2df5234f504f2f22afe9e0b4cf7eeb9ef35
signaturelock-open Commit is signed but in an unrecognized format.

Add a `compiles` wrapper case


1 files changed, 32 insertions(+), 0 deletions(-)

src-self-hosted/test.zig+32
...@@ -120,6 +120,10 @@ pub const TestContext = struct {...@@ -120,6 +120,10 @@ pub const TestContext = struct {
120 }120 }
121 self.updates.append(.{ .src = src, .case = .{ .Error = array } }) catch unreachable;121 self.updates.append(.{ .src = src, .case = .{ .Error = array } }) catch unreachable;
122 }122 }
123
124 pub fn compiles(self: *Case, src: [:0]const u8) void {
125 self.addError(src, &[_][]const u8{});
126 }
123 };127 };
124128
125 pub fn addExe(129 pub fn addExe(
...@@ -260,6 +264,34 @@ pub const TestContext = struct {...@@ -260,6 +264,34 @@ pub const TestContext = struct {
260 ctx.addError(name, target, .ZIR, src, expected_errors);264 ctx.addError(name, target, .ZIR, src, expected_errors);
261 }265 }
262266
267 pub fn addCompiles(
268 ctx: *TestContext,
269 name: []const u8,
270 target: std.zig.CrossTarget,
271 T: TestType,
272 src: [:0]const u8,
273 ) void {
274 ctx.addObj(name, target, T).compiles(src);
275 }
276
277 pub fn compiles(
278 ctx: *TestContext,
279 name: []const u8,
280 target: std.zig.CrossTarget,
281 src: [:0]const u8,
282 ) void {
283 ctx.addCompiles(name, target, .Zig, src);
284 }
285
286 pub fn compilesZIR(
287 ctx: *TestContext,
288 name: []const u8,
289 target: std.zig.CrossTarget,
290 src: [:0]const u8,
291 ) void {
292 ctx.addCompiles(name, target, .ZIR, src);
293 }
294
263 fn init() TestContext {295 fn init() TestContext {
264 const allocator = std.heap.page_allocator;296 const allocator = std.heap.page_allocator;
265 return .{ .cases = std.ArrayList(Case).init(allocator) };297 return .{ .cases = std.ArrayList(Case).init(allocator) };