24 lines
711 B
TypeScript
24 lines
711 B
TypeScript
import { memory } from "./memory"
|
|
import { Word, wordFromNumber, wordFromString } from "./word"
|
|
|
|
describe("memory", () => {
|
|
test("can be created with an initial width", () => {
|
|
const subject = memory(5)
|
|
|
|
expect(subject.value().equals(wordFromString("00000"))).toBe(true)
|
|
})
|
|
|
|
test("can be created from a word", () => {
|
|
const subject = memory(wordFromString("01010"))
|
|
|
|
expect(subject.value().equals(wordFromString("01010"))).toBe(true)
|
|
})
|
|
|
|
test("can be updated with a new word", () => {
|
|
const subject = memory(4)
|
|
|
|
subject.set(wordFromString("1110") as Word<4>)
|
|
|
|
expect(subject.value().equals(wordFromString("1110"))).toBe(true)
|
|
})
|
|
}) |