Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkgs/id/src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl SaveRateLimiter {
if let Some(last) = map.get(name) {
let elapsed = last.elapsed();
if elapsed < self.cooldown {
return Err(self.cooldown.checked_sub(elapsed).unwrap());
return Err(self.cooldown.saturating_sub(elapsed));
}
}
Ok(())
Expand Down
13 changes: 11 additions & 2 deletions pkgs/id/src/world_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,17 @@ mod tests {
)
.unwrap();
let frame = String::from_utf8(world.view().unwrap()).unwrap();
let rows: Vec<&str> = frame.split('\n').collect();
assert_eq!(rows.len(), 3);
let Some(crate::world_presentation::WorldSurface::Screen(screen)) =
crate::world_presentation::parse_surface(&frame).unwrap()
else {
panic!("Roc screen example must return a structured screen");
};
assert_eq!((screen.width, screen.height), (20, 3));
let rows: Vec<String> = screen
.cells
.chunks(usize::from(screen.width))
.map(|row| row.iter().map(|cell| cell.symbol.as_str()).collect())
.collect();
assert!(rows[0].starts_with("+-counter"));
assert!(rows[1].starts_with("| count=1"));
assert_eq!(rows[2], format!("+{}+", "-".repeat(18)));
Expand Down
Loading