-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VMTest passes projects 7 and 8 files
- Loading branch information
1 parent
a613dab
commit 83593b9
Showing
13 changed files
with
296 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { VM_PROJECTS, resetFiles } from "@nand2tetris/projects/index.js"; | ||
import { | ||
FileSystem, | ||
ObjectFileSystemAdapter, | ||
} from "@davidsouther/jiffies/lib/esm/fs.js"; | ||
import { TST } from "../languages/tst.js"; | ||
import { unwrap } from "@davidsouther/jiffies/lib/esm/result.js"; | ||
import { VMTest } from "./vmtst.js"; | ||
|
||
async function prepare(project: "07" | "08", name: string): Promise<VMTest> { | ||
const fs = new FileSystem(new ObjectFileSystemAdapter({})); | ||
await resetFiles(fs); | ||
fs.cd(`/projects/${project}/${name}`); | ||
const vm_tst = await fs.readFile(name + ".vm_tst"); | ||
const tst = unwrap(TST.parse(vm_tst)); | ||
const test = VMTest.from(tst).using(fs); | ||
await test.load(); | ||
return test; | ||
} | ||
|
||
describe("VM Test Runner", () => { | ||
test.each(VM_PROJECTS["07"])("07 VM Test Runner %s", async (name) => { | ||
const test = await prepare("07", name); | ||
|
||
for (let i = 0; i < 100; i++) { | ||
await test.step(); | ||
} | ||
}); | ||
|
||
test.each(VM_PROJECTS["08"])("08 VM Test Runner %s", async (name) => { | ||
const test = await prepare("08", name); | ||
|
||
for (let i = 0; i < 100; i++) { | ||
test.step(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.