char-slop/berry

multipurpose self-modifiable agentic harness

git clone https://git.t4t.associates/char-slop/berry

Charlotte Somcut a bunch of code volumecb11725

main
1.1 KiB22 linesraw
1import { assert, assertEquals } from "@std/assert";
2import { COLORS, contrast, readable } from "./palette.ts";
3
4const [black, red, , yellow] = COLORS.palette;
5
6Deno.test("text that would not read on its background moves just far enough that it does", () => {
7  // black on the terminal's own background, as a prompt's dimmest segment might be, becomes a dark gray
8  const gray = readable(black, COLORS.background);
9  assertEquals(gray[0], gray[1]);
10  assertEquals(gray[1], gray[2]);
11  assert(gray[0] < 128, `${gray} is dark`);
12  // the default foreground on a bright background, as a status bar's might be, darkens
13  const darker = readable(COLORS.foreground, yellow);
14  assert(darker.every((c, i) => c < COLORS.foreground[i]), `${darker} is darker`);
15  for (const [color, background] of [[gray, COLORS.background], [darker, yellow]]) {
16    const ratio = contrast(color, background);
17    assert(ratio >= 3 && ratio < 3.2, `${color} on ${background} reads, and only just: ${ratio}`);
18  }
19  // and anything that reads already stays as it is
20  assertEquals(readable(red, COLORS.background), red);
21  assertEquals(readable(black, yellow), black);
22});