test_this_builtin.zig (415B) - Raw
1 const std = @import("std"); 2 const expect = std.testing.expect; 3 4 test "@This()" { 5 var items = [_]i32{ 1, 2, 3, 4 }; 6 const list = List(i32){ .items = items[0..] }; 7 try expect(list.length() == 4); 8 } 9 10 fn List(comptime T: type) type { 11 return struct { 12 const Self = @This(); 13 14 items: []T, 15 16 fn length(self: Self) usize { 17 return self.items.len; 18 } 19 }; 20 } 21 22 // test