Monorepo for Aesthetic.Computer
aesthetic.computer
1import test from 'node:test';
2import assert from 'node:assert/strict';
3
4import { KidLisp } from '../system/public/aesthetic.computer/lib/kidlisp.mjs';
5
6const COLOR_CODE_MATCH_REGEX = /\\([^\\]+)\\/g;
7const COLOR_CODE_TEST_REGEX = /\\[^\\]+\\/;
8
9test('KidLisp HUD highlight strips color codes cleanly', () => {
10 const source = `$roz : (fade:red-blue:vertical) (line 50 50 100 100) (ink "cyan")`;
11 const kid = new KidLisp();
12 kid.initializeSyntaxHighlighting(source);
13
14 const colored = kid.buildColoredKidlispString();
15 assert.ok(colored.length > 0, 'colored string should not be empty');
16 assert.ok(
17 COLOR_CODE_TEST_REGEX.test(colored),
18 'colored string should contain inline color escapes',
19 );
20
21 COLOR_CODE_MATCH_REGEX.lastIndex = 0;
22 const clean = colored.replace(COLOR_CODE_MATCH_REGEX, '');
23 assert.ok(!clean.includes('\\'), 'stripped text should not display backslashes');
24 assert.ok(clean.includes('line'), 'stripped text should retain Lisp tokens');
25 assert.ok(clean.includes('fade'), 'stripped text should preserve fade directives');
26});