diff --git a/src/root.zig b/src/root.zig index 5778b16..9bc7cde 100644 --- a/src/root.zig +++ b/src/root.zig @@ -13,15 +13,15 @@ pub fn iter(comptime T: type) type { } test fromSliceOwned { - const testing = @import("std").testing; + const expectEqual = std.testing.expectEqual; var it = iter(i32).fromSliceOwned(&.{ 1, 3, 2, 4 }); - try testing.expectEqual(1, it.next()); - try testing.expectEqual(3, it.next()); - try testing.expectEqual(2, it.next()); - try testing.expectEqual(4, it.next()); - try testing.expectEqual(null, it.next()); + try expectEqual(1, it.next()); + try expectEqual(3, it.next()); + try expectEqual(2, it.next()); + try expectEqual(4, it.next()); + try expectEqual(null, it.next()); } pub fn range(start: T, end: T) Iterator(Range(T)) { @@ -39,19 +39,15 @@ pub fn iter(comptime T: type) type { pub const empty: Iterator(Empty(T)) = .{ .inner = .{} }; test empty { - const testing = @import("std").testing; - var it = iter(i32).empty; - try testing.expectEqual(null, it.next()); + try std.testing.expectEqual(null, it.next()); } }; } test iter { - const testing = @import("std").testing; - - const allocator = testing.allocator; + const allocator = std.testing.allocator; const arith = struct { fn is_square(x: i32) bool { @@ -73,7 +69,7 @@ test iter { defer allocator.free(items); - try testing.expectEqualSlices( + try std.testing.expectEqualSlices( i32, &[_]i32{ -100, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, items, @@ -180,15 +176,15 @@ pub fn Iterator(comptime Inner: type) type { } test zip { - const testing = @import("std").testing; + const expectEqualDeep = std.testing.expectEqualDeep; var it = iter(i32).fromSliceOwned(&.{ 1, 2, 3 }) .zip(iter(i32).fromSliceOwned(&.{ 4, 5, 6 })); - try testing.expectEqualDeep(.{ 1, 4 }, it.next()); - try testing.expectEqualDeep(.{ 2, 5 }, it.next()); - try testing.expectEqualDeep(.{ 3, 6 }, it.next()); - try testing.expectEqualDeep(null, it.next()); + try expectEqualDeep(.{ 1, 4 }, it.next()); + try expectEqualDeep(.{ 2, 5 }, it.next()); + try expectEqualDeep(.{ 3, 6 }, it.next()); + try expectEqualDeep(null, it.next()); } pub fn toOwnedSlice(self: Self, allocator: std.mem.Allocator) ![]const Item {