mirror of
https://github.com/ziglang/zig.git
synced 2024-12-04 02:48:50 +00:00
24 lines
545 B
Zig
24 lines
545 B
Zig
|
const std = @import("std");
|
||
|
const testing = std.testing;
|
||
|
const expect = testing.expect;
|
||
|
const expectEqual = testing.expectEqual;
|
||
|
|
||
|
test "self-referential struct through a slice of optional" {
|
||
|
const S = struct {
|
||
|
const Node = struct {
|
||
|
children: []?Node,
|
||
|
data: ?u8,
|
||
|
|
||
|
fn new() Node {
|
||
|
return Node{
|
||
|
.children = undefined,
|
||
|
.data = null,
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
var n = S.Node.new();
|
||
|
try expect(n.data == null);
|
||
|
}
|