Skip to content

Commit 1504e36

Browse files
committed
use comptime test for platform existence
1 parent 80348ef commit 1504e36

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/runtime/js.zig

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,18 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
274274
}
275275

276276
pub fn pumpMessageLoop(self: *const Self) bool {
277-
if (self.platform == null) {
278-
// In test mode only, platform can be null.
279-
if (builtin.is_test) return false;
280-
@panic("platform is null");
277+
if (comptime builtin.is_test) {
278+
if (self.platform == null) return false;
281279
}
280+
// assume it's not-null in non-test.
282281
return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
283282
}
284283

285284
pub fn runIdleTasks(self: *const Self) void {
286-
if (self.platform == null) {
287-
// In test mode only, platform can be null.
288-
if (builtin.is_test) return;
289-
@panic("platform is null");
285+
if (comptime builtin.is_test) {
286+
if (self.platform == null) return;
290287
}
288+
// assume it's not-null in non-test.
291289
return self.platform.?.inner.runIdleTasks(self.isolate, 1);
292290
}
293291

0 commit comments

Comments
 (0)