From 42ba06133aec995feec3ea24ee7fbbc40d7ac2ca Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 9 Jul 2018 10:33:12 -0400 Subject: [PATCH] std.Hashmap - don't use catch unreachable in tests --- std/hash_map.zig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/std/hash_map.zig b/std/hash_map.zig index 3bd03d4f2..cebd5272c 100644 --- a/std/hash_map.zig +++ b/std/hash_map.zig @@ -259,14 +259,14 @@ test "basic hash map usage" { var map = HashMap(i32, i32, hash_i32, eql_i32).init(&direct_allocator.allocator); defer map.deinit(); - assert((map.put(1, 11) catch unreachable) == null); - assert((map.put(2, 22) catch unreachable) == null); - assert((map.put(3, 33) catch unreachable) == null); - assert((map.put(4, 44) catch unreachable) == null); - assert((map.put(5, 55) catch unreachable) == null); + assert((try map.put(1, 11)) == null); + assert((try map.put(2, 22)) == null); + assert((try map.put(3, 33)) == null); + assert((try map.put(4, 44)) == null); + assert((try map.put(5, 55)) == null); - assert((map.put(5, 66) catch unreachable).? == 55); - assert((map.put(5, 55) catch unreachable).? == 66); + assert((try map.put(5, 66)).? == 55); + assert((try map.put(5, 55)).? == 66); assert(map.contains(2)); assert(map.get(2).?.value == 22); @@ -282,9 +282,9 @@ test "iterator hash map" { var reset_map = HashMap(i32, i32, hash_i32, eql_i32).init(&direct_allocator.allocator); defer reset_map.deinit(); - assert((reset_map.put(1, 11) catch unreachable) == null); - assert((reset_map.put(2, 22) catch unreachable) == null); - assert((reset_map.put(3, 33) catch unreachable) == null); + assert((try reset_map.put(1, 11)) == null); + assert((try reset_map.put(2, 22)) == null); + assert((try reset_map.put(3, 33)) == null); var keys = []i32{ 1,