diff options
Diffstat (limited to 'src/bun.js/test')
-rw-r--r-- | src/bun.js/test/diff_format.zig | 4 | ||||
-rw-r--r-- | src/bun.js/test/expect.zig | 6 | ||||
-rw-r--r-- | src/bun.js/test/jest.zig | 22 | ||||
-rw-r--r-- | src/bun.js/test/pretty_format.zig | 34 |
4 files changed, 33 insertions, 33 deletions
diff --git a/src/bun.js/test/diff_format.zig b/src/bun.js/test/diff_format.zig index 4558a5f39..46afa8d0b 100644 --- a/src/bun.js/test/diff_format.zig +++ b/src/bun.js/test/diff_format.zig @@ -104,7 +104,7 @@ pub const DiffFormatter = struct { ZigConsoleClient.format( .Debug, this.globalObject, - @ptrCast([*]const JSValue, &received), + @as([*]const JSValue, @ptrCast(&received)), 1, Writer, Writer, @@ -118,7 +118,7 @@ pub const DiffFormatter = struct { ZigConsoleClient.format( .Debug, this.globalObject, - @ptrCast([*]const JSValue, &this.expected), + @as([*]const JSValue, @ptrCast(&this.expected)), 1, Writer, Writer, diff --git a/src/bun.js/test/expect.zig b/src/bun.js/test/expect.zig index 12f7011fb..e7209e683 100644 --- a/src/bun.js/test/expect.zig +++ b/src/bun.js/test/expect.zig @@ -117,7 +117,7 @@ pub const Expect = struct { const now = std.time.Instant.now() catch unreachable; const pending_test = Jest.runner.?.pending_test.?; const elapsed = @divFloor(now.since(pending_test.started_at), std.time.ns_per_ms); - const remaining = @truncate(u32, Jest.runner.?.last_test_timeout_timer_duration -| elapsed); + const remaining = @as(u32, @truncate(Jest.runner.?.last_test_timeout_timer_duration -| elapsed)); if (!globalThis.bunVM().waitForPromiseWithTimeout(promise, remaining)) { pending_test.timeout(); @@ -2139,7 +2139,7 @@ pub const Expect = struct { active_test_expectation_counter.actual += 1; const not = this.flags.not; - var pass = value.jsType().isArray() and @intCast(i32, value.getLength(globalThis)) == size.toInt32(); + var pass = value.jsType().isArray() and @as(i32, @intCast(value.getLength(globalThis))) == size.toInt32(); if (not) pass = !pass; if (pass) return thisValue; @@ -3003,7 +3003,7 @@ pub const Expect = struct { const times = arguments[0].coerce(i32, globalObject); - var pass = @intCast(i32, calls.getLength(globalObject)) == times; + var pass = @as(i32, @intCast(calls.getLength(globalObject))) == times; const not = this.flags.not; if (not) pass = !pass; diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 4c97b5c77..429b79bcc 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -127,7 +127,7 @@ pub const TestRunner = struct { if (this.last_test_timeout_timer_duration != milliseconds) { this.last_test_timeout_timer_duration = milliseconds; - this.test_timeout_timer.?.set(this, onTestTimeout, @intCast(i32, milliseconds), @intCast(i32, milliseconds)); + this.test_timeout_timer.?.set(this, onTestTimeout, @as(i32, @intCast(milliseconds)), @as(i32, @intCast(milliseconds))); } } } @@ -209,7 +209,7 @@ pub const TestRunner = struct { pub fn addTestCount(this: *TestRunner, count: u32) u32 { this.tests.ensureUnusedCapacity(this.allocator, count) catch unreachable; - const start = @truncate(Test.ID, this.tests.len); + const start = @as(Test.ID, @truncate(this.tests.len)); this.tests.len += count; var statuses = this.tests.items(.status)[start..][0..count]; @memset(statuses, Test.Status.pending); @@ -218,15 +218,15 @@ pub const TestRunner = struct { } pub fn getOrPutFile(this: *TestRunner, file_path: string) *DescribeScope { - var entry = this.index.getOrPut(this.allocator, @truncate(u32, bun.hash(file_path))) catch unreachable; + var entry = this.index.getOrPut(this.allocator, @as(u32, @truncate(bun.hash(file_path)))) catch unreachable; if (entry.found_existing) { return this.files.items(.module_scope)[entry.value_ptr.*]; } var scope = this.allocator.create(DescribeScope) catch unreachable; - const file_id = @truncate(File.ID, this.files.len); + const file_id = @as(File.ID, @truncate(this.files.len)); scope.* = DescribeScope{ .file_id = file_id, - .test_id_start = @truncate(Test.ID, this.tests.len), + .test_id_start = @as(Test.ID, @truncate(this.tests.len)), }; this.files.append(this.allocator, .{ .module_scope = scope, .source = logger.Source.initEmptyFile(file_path) }) catch unreachable; entry.value_ptr.* = file_id; @@ -502,7 +502,7 @@ pub const Jest = struct { JSError(getAllocator(ctx), "Run \"bun test\" to run a test", .{}, ctx, exception); return js.JSValueMakeUndefined(ctx); }; - const arguments = @ptrCast([]const JSC.JSValue, arguments_); + const arguments = @as([]const JSC.JSValue, @ptrCast(arguments_)); if (arguments.len < 1 or !arguments[0].isString()) { JSError(getAllocator(ctx), "Bun.jest() expects a string filename", .{}, ctx, exception); @@ -1077,7 +1077,7 @@ pub const DescribeScope = struct { const file = this.file_id; const allocator = getAllocator(globalObject); var tests: []TestScope = this.tests.items; - const end = @truncate(TestRunner.Test.ID, tests.len); + const end = @as(TestRunner.Test.ID, @truncate(tests.len)); this.pending_tests = std.DynamicBitSetUnmanaged.initFull(allocator, end) catch unreachable; if (end == 0) { @@ -1384,7 +1384,7 @@ pub const TestRunnerTask = struct { fn deinit(this: *TestRunnerTask) void { var vm = JSC.VirtualMachine.get(); if (vm.onUnhandledRejectionCtx) |ctx| { - if (ctx == @ptrCast(*anyopaque, this)) { + if (ctx == @as(*anyopaque, @ptrCast(this))) { vm.onUnhandledRejectionCtx = null; } } @@ -1457,14 +1457,14 @@ inline fn createScope( var timeout_ms: u32 = Jest.runner.?.default_timeout_ms; if (options.isNumber()) { - timeout_ms = @intCast(u32, @max(args[2].coerce(i32, globalThis), 0)); + timeout_ms = @as(u32, @intCast(@max(args[2].coerce(i32, globalThis), 0))); } else if (options.isObject()) { if (options.get(globalThis, "timeout")) |timeout| { if (!timeout.isNumber()) { globalThis.throwPretty("{s} expects timeout to be a number", .{signature}); return .zero; } - timeout_ms = @intCast(u32, @max(timeout.coerce(i32, globalThis), 0)); + timeout_ms = @as(u32, @intCast(@max(timeout.coerce(i32, globalThis), 0))); } if (options.get(globalThis, "retry")) |retries| { if (!retries.isNumber()) { @@ -1642,7 +1642,7 @@ pub fn printGithubAnnotation(exception: *JSC.ZigException) void { var i: i16 = 0; while (i < frames.len) : (i += 1) { - const frame = frames[@intCast(usize, i)]; + const frame = frames[@as(usize, @intCast(i))]; const source_url = frame.source_url.toUTF8(allocator); defer source_url.deinit(); const file = bun.path.relative(dir, source_url.slice()); diff --git a/src/bun.js/test/pretty_format.zig b/src/bun.js/test/pretty_format.zig index e907dd711..7d334d8e7 100644 --- a/src/bun.js/test/pretty_format.zig +++ b/src/bun.js/test/pretty_format.zig @@ -549,7 +549,7 @@ pub const JestPrettyFormat = struct { var writer = WrappedWriter(Writer){ .ctx = writer_ }; var slice = slice_; var i: u32 = 0; - var len: u32 = @truncate(u32, slice.len); + var len: u32 = @as(u32, @truncate(slice.len)); var any_non_ascii = false; while (i < len) : (i += 1) { switch (slice[i]) { @@ -576,7 +576,7 @@ pub const JestPrettyFormat = struct { any_non_ascii = false; slice = slice[@min(slice.len, i + 1)..]; i = 0; - len = @truncate(u32, slice.len); + len = @as(u32, @truncate(slice.len)); const next_value = this.remaining_values[0]; this.remaining_values = this.remaining_values[1..]; switch (token) { @@ -1047,7 +1047,7 @@ pub const JestPrettyFormat = struct { i = -i; } const digits = if (i != 0) - bun.fmt.fastDigitCount(@intCast(usize, i)) + @as(usize, @intFromBool(is_negative)) + bun.fmt.fastDigitCount(@as(usize, @intCast(i))) + @as(usize, @intFromBool(is_negative)) else 1; this.addForNewLine(digits); @@ -1139,7 +1139,7 @@ pub const JestPrettyFormat = struct { } }, .Array => { - const len = @truncate(u32, value.getLength(this.globalThis)); + const len = @as(u32, @truncate(value.getLength(this.globalThis))); if (len == 0) { writer.writeAll("[]"); this.addForNewLine(2); @@ -1250,9 +1250,9 @@ pub const JestPrettyFormat = struct { enable_ansi_colors, ); } else if (value.as(JSC.API.Bun.Timer.TimerObject)) |timer| { - this.addForNewLine("Timeout(# ) ".len + bun.fmt.fastDigitCount(@intCast(u64, @max(timer.id, 0)))); + this.addForNewLine("Timeout(# ) ".len + bun.fmt.fastDigitCount(@as(u64, @intCast(@max(timer.id, 0))))); if (timer.kind == .setInterval) { - this.addForNewLine("repeats ".len + bun.fmt.fastDigitCount(@intCast(u64, @max(timer.id, 0)))); + this.addForNewLine("repeats ".len + bun.fmt.fastDigitCount(@as(u64, @intCast(@max(timer.id, 0))))); writer.print(comptime Output.prettyFmt("<r><blue>Timeout<r> <d>(#<yellow>{d}<r><d>, repeats)<r>", enable_ansi_colors), .{ timer.id, }); @@ -1670,7 +1670,7 @@ pub const JestPrettyFormat = struct { var j: usize = 0; while (j < length) : (j += 1) { - const child = JSC.JSObject.getIndex(children, this.globalThis, @intCast(u32, j)); + const child = JSC.JSObject.getIndex(children, this.globalThis, @as(u32, @intCast(j))); this.format(Tag.get(child, this.globalThis), Writer, writer_, child, this.globalThis, enable_ansi_colors); if (j + 1 < length) { writer.writeAll("\n"); @@ -1827,7 +1827,7 @@ pub const JestPrettyFormat = struct { if (slice.len > 0) { switch (jsType) { .Int8Array => { - const slice_with_type = @alignCast(std.meta.alignment([]i8), std.mem.bytesAsSlice(i8, slice)); + const slice_with_type: []align(std.meta.alignment([]i8)) i8 = @alignCast(std.mem.bytesAsSlice(i8, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1837,7 +1837,7 @@ pub const JestPrettyFormat = struct { } }, .Int16Array => { - const slice_with_type = @alignCast(std.meta.alignment([]i16), std.mem.bytesAsSlice(i16, slice)); + const slice_with_type: []align(std.meta.alignment([]i16)) i16 = @alignCast(std.mem.bytesAsSlice(i16, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1847,7 +1847,7 @@ pub const JestPrettyFormat = struct { } }, .Uint16Array => { - const slice_with_type = @alignCast(std.meta.alignment([]u16), std.mem.bytesAsSlice(u16, slice)); + const slice_with_type: []align(std.meta.alignment([]u16)) u16 = @alignCast(std.mem.bytesAsSlice(u16, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1857,7 +1857,7 @@ pub const JestPrettyFormat = struct { } }, .Int32Array => { - const slice_with_type = @alignCast(std.meta.alignment([]i32), std.mem.bytesAsSlice(i32, slice)); + const slice_with_type: []align(std.meta.alignment([]i32)) i32 = @alignCast(std.mem.bytesAsSlice(i32, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1867,7 +1867,7 @@ pub const JestPrettyFormat = struct { } }, .Uint32Array => { - const slice_with_type = @alignCast(std.meta.alignment([]u32), std.mem.bytesAsSlice(u32, slice)); + const slice_with_type: []align(std.meta.alignment([]u32)) u32 = @alignCast(std.mem.bytesAsSlice(u32, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1877,7 +1877,7 @@ pub const JestPrettyFormat = struct { } }, .Float32Array => { - const slice_with_type = @alignCast(std.meta.alignment([]f32), std.mem.bytesAsSlice(f32, slice)); + const slice_with_type: []align(std.meta.alignment([]f32)) f32 = @alignCast(std.mem.bytesAsSlice(f32, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1887,7 +1887,7 @@ pub const JestPrettyFormat = struct { } }, .Float64Array => { - const slice_with_type = @alignCast(std.meta.alignment([]f64), std.mem.bytesAsSlice(f64, slice)); + const slice_with_type: []align(std.meta.alignment([]f64)) f64 = @alignCast(std.mem.bytesAsSlice(f64, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1897,7 +1897,7 @@ pub const JestPrettyFormat = struct { } }, .BigInt64Array => { - const slice_with_type = @alignCast(std.meta.alignment([]i64), std.mem.bytesAsSlice(i64, slice)); + const slice_with_type: []align(std.meta.alignment([]i64)) i64 = @alignCast(std.mem.bytesAsSlice(i64, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1907,7 +1907,7 @@ pub const JestPrettyFormat = struct { } }, .BigUint64Array => { - const slice_with_type = @alignCast(std.meta.alignment([]u64), std.mem.bytesAsSlice(u64, slice)); + const slice_with_type: []align(std.meta.alignment([]u64)) u64 = @alignCast(std.mem.bytesAsSlice(u64, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { @@ -1919,7 +1919,7 @@ pub const JestPrettyFormat = struct { // Uint8Array, Uint8ClampedArray, DataView, ArrayBuffer else => { - var slice_with_type = @alignCast(std.meta.alignment([]u8), std.mem.bytesAsSlice(u8, slice)); + var slice_with_type: []align(std.meta.alignment([]u8)) u8 = @alignCast(std.mem.bytesAsSlice(u8, slice)); this.indent += 1; defer this.indent -|= 1; for (slice_with_type) |el| { |