mock

package
v0.0.0-...-20a4c11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package mock contains testing mocks and other various utilities for testing code.

Index

Examples

Constants

This section is empty.

Variables

View Source
var AZ26Decoder = func(code uint8) (rune, bool) {
	if code < 1 || code > 26 {
		return 0, false
	}
	return rune(64 + code), true
}
View Source
var (
	TestMemory *rcs.Memory
)

The FUSE tests want the full address space available. Creating memory is expensive and with the amount of tests to run it takes up to 12 seconds to complete. Instead, create memory once and zero out the backing slice each time.

Functions

func MockRead

func MockRead(data []int) func() uint8
Example
data := []int{1, 2, 3}
read := MockRead(data)
fmt.Println(read())
fmt.Println(read())
fmt.Println(read())
Output:

1
2
3

func NewMach

func NewMach() *rcs.Mach

func ResetMemory

func ResetMemory()

ResetMemory zeros out all memory values in TestMemory.

Types

type CPU

type CPU struct {
	A uint8 // sample register
	B uint8 // sample register
	Q bool  // sample flag
	Z bool  // sample flag

	// Offset to be added to the program counter to get the address of the
	// next instruction.
	OffsetPC int
	// contains filtered or unexported fields
}

func NewCPU

func NewCPU(mem *rcs.Memory) *CPU

func (*CPU) Memory

func (c *CPU) Memory() *rcs.Memory

func (*CPU) NewDisassembler

func (c *CPU) NewDisassembler() *rcs.Disassembler

func (*CPU) Next

func (c *CPU) Next()

Next reads the next byte at the program counter as the "opcode". The high nibble is the number of "arguments" it will fetch (max two).

func (*CPU) Offset

func (c *CPU) Offset() int

func (*CPU) PC

func (c *CPU) PC() int

func (*CPU) SetPC

func (c *CPU) SetPC(addr int)

func (*CPU) String

func (c *CPU) String() string

type PanicWriter

type PanicWriter struct {
	// contains filtered or unexported fields
}

PanicWriter is a write that panics after the first newline has been written. Useful for tracking down where warnings are being emitted in the logger.

func (*PanicWriter) Write

func (p *PanicWriter) Write(out []byte) (int, error)

Write appends the output to an internal buffer and then panics with the written text once a newline is found.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL