Monorepo for Aesthetic.Computer
aesthetic.computer
1import assert from "node:assert/strict";
2import { convertNotepatNotation } from "../system/public/aesthetic.computer/lib/notepat-convert.mjs";
3import { parseSimultaneousMelody } from "../system/public/aesthetic.computer/lib/melody-parser.mjs";
4
5function testPreservesWaveSpecifier() {
6 const input = "{triangle}b";
7 const converted = convertNotepatNotation(input);
8 assert.equal(converted, "{triangle}b", "Waveform specifier should remain intact");
9
10 const parsed = parseSimultaneousMelody(converted, 4);
11 assert.equal(parsed.tracks.length, 1, "Should produce a single track");
12 assert.equal(parsed.tracks[0][0].waveType, "triangle", "Parsed note should keep triangle waveform");
13}
14
15function testPreservesNoiseSpecifier() {
16 const input = "{noise-white}b";
17 const converted = convertNotepatNotation(input);
18 assert.equal(converted, "{noise-white}b", "Noise waveform should remain intact");
19
20 const parsed = parseSimultaneousMelody(converted, 4);
21 assert.equal(parsed.tracks[0][0].waveType, "noise-white", "Parsed note should keep noise-white waveform");
22}
23
24function testDigitsInsideBracesDoNotAffectOctave() {
25 const input = "{0.5}c";
26 const converted = convertNotepatNotation(input);
27 assert.equal(converted, "{0.5}c", "Volume spec should remain intact");
28
29 const withNotePat = convertNotepatNotation("4c {0.5}v");
30 assert.equal(withNotePat, "4c {0.5}4cs", "Digits in braces should not change octave tracking");
31}
32
33function testSpeechIsPreserved() {
34 const input = '"ty" v';
35 const converted = convertNotepatNotation(input);
36 assert.equal(converted, '"ty" 4cs', "Speech text should remain unchanged while notepat after quotes converts");
37}
38
39function run() {
40 testPreservesWaveSpecifier();
41 testPreservesNoiseSpecifier();
42 testDigitsInsideBracesDoNotAffectOctave();
43 testSpeechIsPreserved();
44 console.log("✅ clock-notepat-convert tests passed");
45}
46
47run();