Skip to content

Commit 449aefe

Browse files
author
David Souther
committed
Updated biome formatting.
1 parent 68741e1 commit 449aefe

File tree

3 files changed

+105
-113
lines changed

3 files changed

+105
-113
lines changed

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.2.3/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.10/schema.json",
33
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
44
"files": { "ignoreUnknown": false, "includes": ["**/src/**/*.ts"] },
55
"formatter": { "enabled": true, "indentStyle": "space" },

simulator/src/cpu/alu.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ const commandASMValues = new Set([
1919
"D|A",
2020
] as const);
2121

22-
export type COMMANDS_ASM = typeof commandASMValues extends Set<infer S>
23-
? S
24-
: never;
22+
export type COMMANDS_ASM =
23+
typeof commandASMValues extends Set<infer S> ? S : never;
2524

2625
export function isCommandAsm(command: string): command is COMMANDS_ASM {
2726
return (
@@ -161,9 +160,8 @@ const assignAsmValues = new Set([
161160
"AMD",
162161
] as const);
163162

164-
export type ASSIGN_ASM = typeof assignAsmValues extends Set<infer S>
165-
? S
166-
: never;
163+
export type ASSIGN_ASM =
164+
typeof assignAsmValues extends Set<infer S> ? S : never;
167165

168166
export type ASSIGN_OP = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
169167

simulator/src/projects/all.test.ts

Lines changed: 100 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -34,129 +34,123 @@ const SKIP = new Set<string>([]);
3434
const INCLUDE = new Set<string>(["And", "And16", "Mux8Way16", "Bit"]);
3535

3636
describe("Chip Projects", () => {
37-
describe.each(Object.keys(CHIP_PROJECTS).filter((k) => PROJECTS.has(k)))(
38-
"project %s",
39-
(project) => {
40-
it.each(
41-
CHIP_PROJECTS[project as keyof typeof CHIP_PROJECTS]
42-
.filter((k) => !SKIP.has(k))
43-
.filter((k) => INCLUDE.has(k)),
44-
)("Chip %s", async (chipName) => {
45-
const chipProject = {
46-
// @ts-ignore
47-
...assertExists(ChipProjects[project]),
48-
// @ts-ignore
49-
...assertExists(ChipProjectsSols[project]),
50-
};
51-
const hdlFile = chipProject.SOLS[chipName]?.[`${chipName}.hdl`];
52-
const tstFile = chipProject.CHIPS?.[`${chipName}.tst`];
53-
const cmpFile = chipProject.CHIPS?.[`${chipName}.cmp`];
54-
55-
expect(hdlFile).toBeDefined();
56-
expect(tstFile).toBeDefined();
57-
expect(cmpFile).toBeDefined();
58-
59-
const hdl = HDL.parse(hdlFile);
60-
expect(hdl).toBeOk();
61-
const tst = TST.parse(tstFile);
62-
expect(tst).toBeOk();
63-
64-
const chip = await build({ parts: Ok(hdl as Ok<HdlParse>) });
65-
expect(chip).toBeOk();
66-
const test = unwrap(ChipTest.from(Ok(tst as Ok<Tst>))).with(
67-
Ok(chip as Ok<Chip>),
37+
describe.each(
38+
Object.keys(CHIP_PROJECTS).filter((k) => PROJECTS.has(k)),
39+
)("project %s", (project) => {
40+
it.each(
41+
CHIP_PROJECTS[project as keyof typeof CHIP_PROJECTS]
42+
.filter((k) => !SKIP.has(k))
43+
.filter((k) => INCLUDE.has(k)),
44+
)("Chip %s", async (chipName) => {
45+
const chipProject = {
46+
// @ts-ignore
47+
...assertExists(ChipProjects[project]),
48+
// @ts-ignore
49+
...assertExists(ChipProjectsSols[project]),
50+
};
51+
const hdlFile = chipProject.SOLS[chipName]?.[`${chipName}.hdl`];
52+
const tstFile = chipProject.CHIPS?.[`${chipName}.tst`];
53+
const cmpFile = chipProject.CHIPS?.[`${chipName}.cmp`];
54+
55+
expect(hdlFile).toBeDefined();
56+
expect(tstFile).toBeDefined();
57+
expect(cmpFile).toBeDefined();
58+
59+
const hdl = HDL.parse(hdlFile);
60+
expect(hdl).toBeOk();
61+
const tst = TST.parse(tstFile);
62+
expect(tst).toBeOk();
63+
64+
const chip = await build({ parts: Ok(hdl as Ok<HdlParse>) });
65+
expect(chip).toBeOk();
66+
const test = unwrap(ChipTest.from(Ok(tst as Ok<Tst>))).with(
67+
Ok(chip as Ok<Chip>),
68+
);
69+
70+
if (chipName === "Computer") {
71+
test.setFileSystem(
72+
new FileSystem(new ObjectFileSystemAdapter({ "Max.hack": Max })),
6873
);
74+
}
6975

70-
if (chipName === "Computer") {
71-
test.setFileSystem(
72-
new FileSystem(new ObjectFileSystemAdapter({ "Max.hack": Max })),
73-
);
74-
}
75-
76-
await test.run();
76+
await test.run();
7777

78-
const outFile = test.log();
78+
const outFile = test.log();
7979

80-
const cmp = CMP.parse(cmpFile);
81-
expect(cmp).toBeOk();
82-
const out = CMP.parse(outFile);
83-
expect(out).toBeOk();
80+
const cmp = CMP.parse(cmpFile);
81+
expect(cmp).toBeOk();
82+
const out = CMP.parse(outFile);
83+
expect(out).toBeOk();
8484

85-
const diffs = compare(Ok(cmp as Ok<Cmp>), Ok(out as Ok<Cmp>));
86-
expect(diffs).toHaveNoDiff();
87-
});
88-
},
89-
);
85+
const diffs = compare(Ok(cmp as Ok<Cmp>), Ok(out as Ok<Cmp>));
86+
expect(diffs).toHaveNoDiff();
87+
});
88+
});
9089
});
9190

9291
describe("ASM Projects", () => {
93-
describe.each(Object.keys(ASM_PROJECTS))(
94-
"project %s",
95-
(project) => {
96-
it.each(Object.keys(ASM_FILES))("%s", (file_name) => {
97-
const source = ASM_FILES[file_name as keyof typeof ASM_FILES];
98-
const parsed = ASM.parse(source);
99-
expect(parsed).toBeOk();
100-
const asm = Ok(parsed as Ok<Asm>);
101-
ASM.passes.fillLabel(asm);
102-
const filled = ASM.passes.emit(asm);
103-
expect(filled).toEqual(ASM_SOLS[file_name as keyof typeof ASM_FILES]);
104-
});
105-
},
106-
15_000, // timeout
107-
);
92+
describe.each(Object.keys(ASM_PROJECTS))("project %s", (project) => {
93+
it.each(Object.keys(ASM_FILES))("%s", (file_name) => {
94+
const source = ASM_FILES[file_name as keyof typeof ASM_FILES];
95+
const parsed = ASM.parse(source);
96+
expect(parsed).toBeOk();
97+
const asm = Ok(parsed as Ok<Asm>);
98+
ASM.passes.fillLabel(asm);
99+
const filled = ASM.passes.emit(asm);
100+
expect(filled).toEqual(ASM_SOLS[file_name as keyof typeof ASM_FILES]);
101+
});
102+
}, 15_000); // timeout
108103
});
109104

110105
describe("Vm Projects", () => {
111-
describe.each(Object.keys(VM_PROJECTS).filter((k) => PROJECTS.has(k)))(
112-
"project %s",
113-
(project) => {
114-
it.each(
115-
VM_PROJECTS[project as keyof typeof VM_PROJECTS].filter(
116-
(k) => !SKIP.has(k),
117-
),
118-
)("VM Program %s", async (vmName) => {
119-
const vmProject = {
120-
// @ts-ignore
121-
...assertExists(VmProjects[project]),
122-
};
123-
124-
const tstFile = vmProject.VMS[vmName]?.[`${vmName}VME.tst`];
125-
const cmpFile = vmProject.VMS[vmName]?.[`${vmName}.cmp`];
126-
127-
let vmCode = "";
128-
for (const filename of Object.keys(vmProject.VMS[vmName])) {
129-
if (filename.endsWith(".vm")) {
130-
const vmFile = vmProject.VMS[vmName]?.[filename];
131-
expect(vmFile).toBeDefined();
132-
vmCode += vmFile;
133-
}
106+
describe.each(
107+
Object.keys(VM_PROJECTS).filter((k) => PROJECTS.has(k)),
108+
)("project %s", (project) => {
109+
it.each(
110+
VM_PROJECTS[project as keyof typeof VM_PROJECTS].filter(
111+
(k) => !SKIP.has(k),
112+
),
113+
)("VM Program %s", async (vmName) => {
114+
const vmProject = {
115+
// @ts-ignore
116+
...assertExists(VmProjects[project]),
117+
};
118+
119+
const tstFile = vmProject.VMS[vmName]?.[`${vmName}VME.tst`];
120+
const cmpFile = vmProject.VMS[vmName]?.[`${vmName}.cmp`];
121+
122+
let vmCode = "";
123+
for (const filename of Object.keys(vmProject.VMS[vmName])) {
124+
if (filename.endsWith(".vm")) {
125+
const vmFile = vmProject.VMS[vmName]?.[filename];
126+
expect(vmFile).toBeDefined();
127+
vmCode += vmFile;
134128
}
129+
}
135130

136-
expect(tstFile).toBeDefined();
137-
expect(cmpFile).toBeDefined();
131+
expect(tstFile).toBeDefined();
132+
expect(cmpFile).toBeDefined();
138133

139-
const parsed = VM.parse(vmCode);
140-
expect(parsed).toBeOk();
141-
const tst = TST.parse(tstFile);
142-
expect(tst).toBeOk();
134+
const parsed = VM.parse(vmCode);
135+
expect(parsed).toBeOk();
136+
const tst = TST.parse(tstFile);
137+
expect(tst).toBeOk();
143138

144-
const vm = await Vm.build(unwrap(parsed).instructions);
145-
expect(vm).toBeOk();
146-
const test = unwrap(VMTest.from(unwrap(tst))).with(unwrap(vm));
139+
const vm = await Vm.build(unwrap(parsed).instructions);
140+
expect(vm).toBeOk();
141+
const test = unwrap(VMTest.from(unwrap(tst))).with(unwrap(vm));
147142

148-
await test.run();
143+
await test.run();
149144

150-
const outFile = test.log();
145+
const outFile = test.log();
151146

152-
const cmp = CMP.parse(cmpFile);
153-
expect(cmp).toBeOk();
154-
const out = CMP.parse(outFile);
155-
expect(out).toBeOk();
147+
const cmp = CMP.parse(cmpFile);
148+
expect(cmp).toBeOk();
149+
const out = CMP.parse(outFile);
150+
expect(out).toBeOk();
156151

157-
const diffs = compare(unwrap(cmp), unwrap(out));
158-
expect(diffs).toHaveNoDiff();
159-
});
160-
},
161-
);
152+
const diffs = compare(unwrap(cmp), unwrap(out));
153+
expect(diffs).toHaveNoDiff();
154+
});
155+
});
162156
});

0 commit comments

Comments
 (0)