add regression test for struct with optional list of self

closes #1735
This commit is contained in:
Andrew Kelley 2019-08-27 14:06:17 -04:00
parent 428a2fdedd
commit c1fd7ed6e2
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 47 additions and 0 deletions

View File

@ -23,6 +23,7 @@ comptime {
_ = @import("behavior/bugs/1486.zig");
_ = @import("behavior/bugs/1500.zig");
_ = @import("behavior/bugs/1607.zig");
_ = @import("behavior/bugs/1735.zig");
_ = @import("behavior/bugs/1851.zig");
_ = @import("behavior/bugs/1914.zig");
_ = @import("behavior/bugs/2006.zig");

View File

@ -0,0 +1,46 @@
const std = @import("std");
const mystruct = struct {
pending: ?listofstructs,
};
pub fn TailQueue(comptime T: type) type {
return struct {
const Self = @This();
pub const Node = struct {
prev: ?*Node,
next: ?*Node,
data: T,
};
first: ?*Node,
last: ?*Node,
len: usize,
pub fn init() Self {
return Self{
.first = null,
.last = null,
.len = 0,
};
}
};
}
const listofstructs = TailQueue(mystruct);
const a = struct {
const Self = @This();
foo: listofstructs,
pub fn init() Self {
return Self{
.foo = listofstructs.init(),
};
}
};
test "intialization" {
var t = a.init();
std.testing.expect(t.foo.len == 0);
}