char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
cb11725
main
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 8const gray = readable ( black , COLORS . background ); 9assertEquals ( gray [ 0 ], gray [ 1 ]); 10assertEquals ( gray [ 1 ], gray [ 2 ]); 11assert ( gray [ 0 ] < 128 , ` ${ gray } is dark` ); 12// the default foreground on a bright background, as a status bar's might be, darkens 13const darker = readable ( COLORS . foreground , yellow ); 14assert ( darker . every (( c , i ) => c < COLORS . foreground [ i ]), ` ${ darker } is darker` ); 15for ( const [ color , background ] of [[ gray , COLORS . background ], [ darker , yellow ]]) { 16const ratio = contrast ( color , background ); 17assert ( ratio >= 3 && ratio < 3.2 , ` ${ color } on ${ background } reads, and only just: ${ ratio } ` ); 18} 19// and anything that reads already stays as it is 20assertEquals ( readable ( red , COLORS . background ), red ); 21assertEquals ( readable ( black , yellow ), black ); 22});