summaryrefslogtreecommitdiff
path: root/src/locations.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 00:52:52 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit5157579ff7f9ae0cfc3c7629e953da05bce340fc (patch)
tree02147789efdcea998981efcfe05d4bcb3e9bb7b0 /src/locations.zig
parent4c4b9bf54d77dbc0f9f4e2619746908e501c6001 (diff)
downloadpardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.tar.gz
pardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.zip
tests: at the end of their files: every top-level test block of the 46 files that had one mid-file (the locality analysis's 45 and test/hxdiff.zig; gui.zig, macos.zig, look, host_io, 9p_io, terminal, tui, mouse, fs, replica, layout among them, 11,429 test lines), with the functions only tests call, moved after the file's code in their order, a mechanical move (.scratch/suites/tests_to_end.py), zig fmt'd; the unit suites pass as before (tui 1486/1487, gui 1536/1537, core 956/956 on both), macos.zig only parse-checked here
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/locations.zig')
-rw-r--r--src/locations.zig80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/locations.zig b/src/locations.zig
index f6a0cf9c..fc39f92d 100644
--- a/src/locations.zig
+++ b/src/locations.zig
@@ -646,20 +646,6 @@ fn appendContext(arena: std.mem.Allocator, rows: *std.ArrayList(Pending), path:
});
}
-test "locations tab delimiter preserves source indentation and spaced paths" {
- const row = parse("some directory/界.zig:12:3-5 \t\t value");
- try std.testing.expectEqualStrings("some directory/界.zig", row.path);
- try std.testing.expectEqual(@as(usize, 12), row.at.line);
- try std.testing.expectEqualStrings("\t value", "some directory/界.zig:12:3-5 \t\t value"[row.code_start..]);
-}
-
-test "locations native results retain the first source tab" {
- const text = "some directory/a.zig:3:2 \t value";
- const row = parseRaw(text);
- try std.testing.expectEqualStrings("some directory/a.zig", row.path);
- try std.testing.expectEqualStrings("\t value", text[row.code_start..]);
-}
-
// ---- the Locations setting ----
pub const Config = struct {
@@ -712,32 +698,6 @@ pub const Config = struct {
}
};
-test "LocationsConfig reflection round trip and partial updates" {
- var config: Config = .{};
- config = try config.parse("context:5 tscontext:on");
- config = try config.parse("tslocations:off");
- try std.testing.expectEqual(Config{ .context = 5, .tscontext = true, .tslocations = false }, config);
- var out: std.Io.Writer.Allocating = .init(std.testing.allocator);
- defer out.deinit();
- try config.write(&out.writer);
- try std.testing.expectEqualStrings("context:5 tscontext:on tslocations:off layout:stacked", out.written());
- try std.testing.expectEqual(config, try (Config{}).parse(out.written()));
- try std.testing.expectEqual(config, try config.parse(" \n\t"));
- try std.testing.expectEqual(@as(u16, 2), (try config.parse("context:1 context:2")).context);
- try std.testing.expectEqual(Config.Layout.@"inline", (try config.parse("layout:inline")).layout);
-}
-
-test "LocationsConfig rejects invalid updates atomically" {
- const config: Config = .{ .context = 3, .tscontext = true };
- try std.testing.expectError(error.UnknownLocationSetting, config.parse("context:5 unknown:on"));
- try std.testing.expectError(error.ExpectedOnOrOff, config.parse("context:5 tscontext:true"));
- try std.testing.expectError(error.ExpectedKeyValue, config.parse("context"));
- try std.testing.expectError(error.InvalidLayout, config.parse("context:5 layout:sideways"));
- for ([_][]const u8{ "context:", "context:-1", "context:65536", "context:five" }) |input|
- try std.testing.expectError(error.InvalidContext, config.parse(input));
- try std.testing.expectEqual(@as(u16, 3), config.context);
-}
-
// ---- the analysis cache ----
/// Owned source snapshots keep analysis valid across filesystem changes and
@@ -890,6 +850,46 @@ pub const Cache = struct {
}
};
+test "locations tab delimiter preserves source indentation and spaced paths" {
+ const row = parse("some directory/界.zig:12:3-5 \t\t value");
+ try std.testing.expectEqualStrings("some directory/界.zig", row.path);
+ try std.testing.expectEqual(@as(usize, 12), row.at.line);
+ try std.testing.expectEqualStrings("\t value", "some directory/界.zig:12:3-5 \t\t value"[row.code_start..]);
+}
+
+test "locations native results retain the first source tab" {
+ const text = "some directory/a.zig:3:2 \t value";
+ const row = parseRaw(text);
+ try std.testing.expectEqualStrings("some directory/a.zig", row.path);
+ try std.testing.expectEqualStrings("\t value", text[row.code_start..]);
+}
+
+test "LocationsConfig reflection round trip and partial updates" {
+ var config: Config = .{};
+ config = try config.parse("context:5 tscontext:on");
+ config = try config.parse("tslocations:off");
+ try std.testing.expectEqual(Config{ .context = 5, .tscontext = true, .tslocations = false }, config);
+ var out: std.Io.Writer.Allocating = .init(std.testing.allocator);
+ defer out.deinit();
+ try config.write(&out.writer);
+ try std.testing.expectEqualStrings("context:5 tscontext:on tslocations:off layout:stacked", out.written());
+ try std.testing.expectEqual(config, try (Config{}).parse(out.written()));
+ try std.testing.expectEqual(config, try config.parse(" \n\t"));
+ try std.testing.expectEqual(@as(u16, 2), (try config.parse("context:1 context:2")).context);
+ try std.testing.expectEqual(Config.Layout.@"inline", (try config.parse("layout:inline")).layout);
+}
+
+test "LocationsConfig rejects invalid updates atomically" {
+ const config: Config = .{ .context = 3, .tscontext = true };
+ try std.testing.expectError(error.UnknownLocationSetting, config.parse("context:5 unknown:on"));
+ try std.testing.expectError(error.ExpectedOnOrOff, config.parse("context:5 tscontext:true"));
+ try std.testing.expectError(error.ExpectedKeyValue, config.parse("context"));
+ try std.testing.expectError(error.InvalidLayout, config.parse("context:5 layout:sideways"));
+ for ([_][]const u8{ "context:", "context:-1", "context:65536", "context:five" }) |input|
+ try std.testing.expectError(error.InvalidContext, config.parse(input));
+ try std.testing.expectEqual(@as(u16, 3), config.context);
+}
+
test "locations cache validates exact source and path and upgrades analysis" {
const gpa = std.testing.allocator;
syntax.start(gpa);