aboutsummaryrefslogtreecommitdiff
path: root/test/self_hosted.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-05-07 17:00:58 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-05-07 17:00:58 -0700
commit2ed72022ce56b06bb3e90ca9259065452e209eb9 (patch)
treee583301a3d037577ee8aff73f5ad91177d72c98f /test/self_hosted.zig
parent01c46eef3a7e4fd5a96f364541c539746ae1ea3b (diff)
downloadzig-2ed72022ce56b06bb3e90ca9259065452e209eb9.tar.gz
zig-2ed72022ce56b06bb3e90ca9259065452e209eb9.zip
support generic data structures
See #22
Diffstat (limited to 'test/self_hosted.zig')
-rw-r--r--test/self_hosted.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/self_hosted.zig b/test/self_hosted.zig
index 8c6c9112e4..36c0cc9d6f 100644
--- a/test/self_hosted.zig
+++ b/test/self_hosted.zig
@@ -1566,3 +1566,15 @@ fn c_string_concatenation() {
assert(a[len] == 0);
assert(b[len] == 0);
}
+
+#attribute("test")
+fn generic_struct() {
+ var a1 = GenNode(i32) {.value = 13, .next = null,};
+ var b1 = GenNode(bool) {.value = true, .next = null,};
+ assert(a1.value == 13);
+ assert(b1.value);
+}
+struct GenNode(T: type) {
+ value: T,
+ next: ?&GenNode(T),
+}