MCPcopy Create free account
hub / github.com/djhworld/simple-computer / TestRegisterWordIsSet

Function TestRegisterWordIsSet

components/register_test.go:9–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestRegisterWordIsSet(t *testing.T) {
10 b := NewBus(arch.BUS_WIDTH)
11 setBus(b, 0x3957)
12
13 r := NewRegister("r", b, b)
14
15 r.Set()
16 r.Disable()
17 r.Update()
18
19 if !checkValueIs(r.word, 0x3957) {
20 t.Fail()
21 }
22
23 r.Unset()
24 setBus(b, 0xFE21)
25 r.Update()
26
27 // value should not change
28 if !checkValueIs(r.word, 0x3957) {
29 t.Fail()
30 }
31
32 r.Set()
33 setBus(b, 0x0039)
34 r.Update()
35
36 // value should change
37 if !checkValueIs(r.word, 0x0039) {
38 t.Fail()
39 }
40}
41
42func TestRegisterOutputIsZeroWhenDisabled(t *testing.T) {
43 b := NewBus(arch.BUS_WIDTH)

Callers

nothing calls this directly

Calls 8

SetMethod · 0.95
DisableMethod · 0.95
UpdateMethod · 0.95
UnsetMethod · 0.95
NewBusFunction · 0.85
setBusFunction · 0.85
NewRegisterFunction · 0.85
checkValueIsFunction · 0.85

Tested by

no test coverage detected