@@ -173,8 +173,8 @@ const TestContext = struct {
173173
174174 pub fn processMessage (self : * TestContext , msg : anytype ) ! void {
175175 var json_message : []const u8 = undefined ;
176- if (@typeInfo (@TypeOf (msg )) != .Pointer ) {
177- json_message = try json .stringifyAlloc (self .arena .allocator (), msg , .{});
176+ if (@typeInfo (@TypeOf (msg )) != .pointer ) {
177+ json_message = try std . json .stringifyAlloc (self .arena .allocator (), msg , .{});
178178 } else {
179179 // assume this is a string we want to send as-is, if it isn't, we'll
180180 // get a compile error, so no big deal.
@@ -195,7 +195,7 @@ const TestContext = struct {
195195 pub fn expectSentResult (self : * TestContext , expected : anytype , opts : ExpectResultOpts ) ! void {
196196 const expected_result = .{
197197 .id = opts .id ,
198- .result = if (comptime @typeInfo (@TypeOf (expected )) == .Null ) struct {}{} else expected ,
198+ .result = if (comptime @typeInfo (@TypeOf (expected )) == .null ) struct {}{} else expected ,
199199 .sessionId = opts .session_id ,
200200 };
201201
@@ -209,7 +209,7 @@ const TestContext = struct {
209209 pub fn expectSentEvent (self : * TestContext , method : []const u8 , params : anytype , opts : ExpectEventOpts ) ! void {
210210 const expected_event = .{
211211 .method = method ,
212- .params = if (comptime @typeInfo (@TypeOf (params )) == .Null ) struct {}{} else params ,
212+ .params = if (comptime @typeInfo (@TypeOf (params )) == .null ) struct {}{} else params ,
213213 .sessionId = opts .session_id ,
214214 };
215215
@@ -321,96 +321,3 @@ fn compareJsonValues(a: std.json.Value, b: std.json.Value) bool {
321321 },
322322 }
323323}
324-
325- // fn compareAnyToJsonValue(expected: anytype, actual: json.Value) bool {
326- // switch (@typeInfo(@TypeOf(expected))) {
327- // .Optional => {
328- // if (expected) |e| {
329- // return compareAnyToJsonValue(e, actual);
330- // }
331- // return actual == .null;
332- // },
333- // .Int, .ComptimeInt => {
334- // if (actual != .integer) {
335- // return false;
336- // }
337- // return expected == actual.integer;
338- // },
339- // .Float, .ComptimeFloat => {
340- // if (actual != .float) {
341- // return false;
342- // }
343- // return expected == actual.float;
344- // },
345- // .Bool => {
346- // if (actual != .bool) {
347- // return false;
348- // }
349- // return expected == actual.bool;
350- // },
351- // .Pointer => |ptr| switch (ptr.size) {
352- // .One => switch (@typeInfo(ptr.child)) {
353- // .Struct => return compareAnyToJsonValue(expected.*, actual),
354- // .Array => |arr| if (arr.child == u8) {
355- // if (actual != .string) {
356- // return false;
357- // }
358- // return std.mem.eql(u8, expected, actual.string);
359- // },
360- // else => {},
361- // },
362- // .Slice => switch (ptr.child) {
363- // u8 => {
364- // if (actual != .string) {
365- // return false;
366- // }
367- // return std.mem.eql(u8, expected, actual.string);
368- // },
369- // else => {},
370- // },
371- // else => {},
372- // },
373- // .Struct => |s| {
374- // if (s.is_tuple) {
375- // // how an array might look in an anytype
376- // if (actual != .array) {
377- // return false;
378- // }
379- // if (s.fields.len != actual.array.items.len) {
380- // return false;
381- // }
382-
383- // inline for (s.fields, 0..) |f, i| {
384- // const e = @field(expected, f.name);
385- // if (compareAnyToJsonValue(e, actual.array.items[i]) == false) {
386- // return false;
387- // }
388- // }
389- // return true;
390- // }
391-
392- // if (s.fields.len == 0) {
393- // return (actual == .array and actual.array.items.len == 0);
394- // }
395-
396- // if (actual != .object) {
397- // return false;
398- // }
399- // inline for (s.fields) |f| {
400- // const e = @field(expected, f.name);
401- // if (actual.object.get(f.name)) |a| {
402- // if (compareAnyToJsonValue(e, a) == false) {
403- // return false;
404- // }
405- // } else if (@typeInfo(f.type) != .Optional or e != null) {
406- // // We don't JSON serialize nulls. So if we're expecting
407- // // a null, that should show up as a missing field.
408- // return false;
409- // }
410- // }
411- // return true;
412- // },
413- // else => {},
414- // }
415- // @compileError("Can't compare " ++ @typeName(@TypeOf(expected)));
416- // }
0 commit comments