Skip to content

Commit 5cfbb0d

Browse files
committed
update tests
1 parent 92d853d commit 5cfbb0d

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/TrigramStore.zig

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
const std = @import("std");
44
const ast = @import("ast.zig");
55
const Ast = std.zig.Ast;
6-
const builtin = @import("builtin");
76
const assert = std.debug.assert;
87
const offsets = @import("offsets.zig");
9-
const URI = @import("uri.zig");
10-
const log = std.log.scoped(.store);
118

129
pub const TrigramStore = @This();
1310

@@ -239,7 +236,7 @@ fn mergeIntersection(
239236
b: []const Declaration.Index,
240237
out: []Declaration.Index,
241238
) u32 {
242-
std.debug.assert(@min(a.len, b.len) <= out.len);
239+
assert(@min(a.len, b.len) <= out.len);
243240

244241
var out_idx: u32 = 0;
245242

@@ -438,17 +435,17 @@ test CuckooFilter {
438435
try entries.ensureTotalCapacity(allocator, element_count);
439436

440437
var buckets: [filter_size]CuckooFilter.Bucket = undefined;
441-
var filter = CuckooFilter{ .buckets = &buckets };
442-
var filter_prng = std.Random.DefaultPrng.init(42);
438+
var filter: CuckooFilter = .{ .buckets = &buckets };
439+
var filter_prng: std.Random.DefaultPrng = .init(42);
443440

444441
for (0..2_500) |gen_prng_seed| {
445442
entries.clearRetainingCapacity();
446443
filter.reset();
447444

448-
var gen_prng = std.Random.DefaultPrng.init(gen_prng_seed);
445+
var gen_prng: std.Random.DefaultPrng = .init(gen_prng_seed);
449446
for (0..element_count) |_| {
450447
const trigram: Trigram = @bitCast(gen_prng.random().int(u24));
451-
try entries.put(allocator, trigram, {});
448+
entries.putAssumeCapacity(allocator, trigram, {});
452449
try filter.append(filter_prng.random(), trigram);
453450
}
454451

@@ -460,7 +457,7 @@ test CuckooFilter {
460457
// Reasonable false positive rate
461458
const fpr_count = 2_500;
462459
var false_positives: usize = 0;
463-
var negative_prng = std.Random.DefaultPrng.init(~gen_prng_seed);
460+
var negative_prng: std.Random.DefaultPrng = .init(~gen_prng_seed);
464461
for (0..fpr_count) |_| {
465462
var trigram: Trigram = @bitCast(negative_prng.random().int(u24));
466463
while (entries.contains(trigram)) {
@@ -471,9 +468,8 @@ test CuckooFilter {
471468
}
472469

473470
const fpr = @as(f32, @floatFromInt(false_positives)) / fpr_count;
474-
std.testing.expect(fpr < 0.035) catch |err| {
475-
std.log.err("fpr: {d}%", .{fpr * 100});
476-
return err;
477-
};
471+
472+
errdefer std.log.err("fpr: {d}%", .{fpr * 100});
473+
try std.testing.expect(fpr < 0.035);
478474
}
479475
}

tests/analysis_check.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub fn main() Error!void {
140140
defer gpa.free(source);
141141

142142
const handle_uri = try zls.URI.fromPath(arena, file_path);
143-
try document_store.openDocument(handle_uri, source);
143+
try document_store.openLspSyncedDocument(handle_uri, source);
144144
const handle: *zls.DocumentStore.Handle = document_store.handles.get(handle_uri).?;
145145

146146
var error_builder: ErrorBuilder = .init(gpa);

tests/lsp_features/code_actions.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ fn testDiagnostic(
996996

997997
const actual = try zls.diff.applyTextEdits(allocator, source, text_edits.items, ctx.server.offset_encoding);
998998
defer allocator.free(actual);
999-
try ctx.server.document_store.refreshDocument(uri, try allocator.dupeZ(u8, actual));
999+
try ctx.server.document_store.refreshLspSyncedDocument(uri, try allocator.dupeZ(u8, actual));
10001000

10011001
try std.testing.expectEqualStrings(after, handle.tree.source);
10021002
}

0 commit comments

Comments
 (0)