debug

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

The debug package is great for testing and debugging of parser.Interface implementations.

Code generated by debug-gen. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var Input = &Debug{
	A: int64(1),
	B: []string{"b2", "b3"},
	C: &Debug{
		A: int64(2),
		D: proto.Int32(3),
		E: []*Debug{
			{
				B: []string{"b4"},
			},
			{
				B: []string{"b5"},
			},
		},
	},
	D: proto.Int32(4),
	F: []uint32{5},
}

Input is a sample instance of the Debug struct.

View Source
var Output = Nodes{
	Field(`A`, `1`),
	Nested(`B`,
		Field(`0`, `b2`),
		Field(`1`, `b3`),
	),
	Nested(`C`,
		Field(`A`, `2`),
		Field(`D`, `3`),
		Nested(`E`,
			Nested(`0`,
				Field(`A`, `0`),
				Nested(`B`,
					Field(`0`, `b4`),
				),
			),
			Nested(`1`,
				Field(`A`, `0`),
				Nested(`B`,
					Field(`0`, `b5`),
				),
			),
		),
	),
	Field(`D`, `4`),
	Nested(`F`,
		Field(`0`, `5`),
	),
}

Output is a sample instance of Nodes that repesents the Input variable after it has been parsed by Walk.

Functions

func NewBoolValue

func NewBoolValue(v bool) parser.Value

NewBoolValue wraps a native go type into a parser.Value.

func NewBytesValue

func NewBytesValue(v []byte) parser.Value

NewBytesValue wraps a native go type into a parser.Value.

func NewDoubleValue

func NewDoubleValue(v float64) parser.Value

NewDoubleValue wraps a native go type into a parser.Value.

func NewIntValue

func NewIntValue(v int64) parser.Value

NewIntValue wraps a native go type into a parser.Value.

func NewLogger

func NewLogger(s parser.Interface, logger Logger) parser.Interface

NewLogger returns a parser that when called returns and logs the value returned by the argument parser to the argument logger.

func NewStringValue

func NewStringValue(v string) parser.Value

NewStringValue wraps a native go type into a parser.Value.

func NewUintValue

func NewUintValue(v uint64) parser.Value

NewUintValue wraps a native go type into a parser.Value.

Types

type Debug

type Debug struct {
	A                int64    `protobuf:"varint,1,opt,name=A" json:"A"`
	B                []string `protobuf:"bytes,2,rep,name=B" json:"B,omitempty"`
	C                *Debug   `protobuf:"bytes,3,opt,name=C" json:"C,omitempty"`
	D                *int32   `protobuf:"varint,4,opt,name=D" json:"D,omitempty"`
	E                []*Debug `protobuf:"bytes,5,rep,name=E" json:"E,omitempty"`
	F                []uint32 `protobuf:"fixed32,6,rep,name=F" json:"F,omitempty"`
	G                *float64 `protobuf:"fixed64,7,opt,name=G" json:"G,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func (*Debug) Descriptor

func (*Debug) Descriptor() ([]byte, []int)

func (*Debug) GetA

func (m *Debug) GetA() int64

func (*Debug) GetB

func (m *Debug) GetB() []string

func (*Debug) GetC

func (m *Debug) GetC() *Debug

func (*Debug) GetD

func (m *Debug) GetD() int32

func (*Debug) GetE

func (m *Debug) GetE() []*Debug

func (*Debug) GetF

func (m *Debug) GetF() []uint32

func (*Debug) GetG

func (m *Debug) GetG() float64

func (*Debug) GoString

func (this *Debug) GoString() string

func (*Debug) ProtoMessage

func (*Debug) ProtoMessage()

func (*Debug) Reset

func (m *Debug) Reset()

func (*Debug) String

func (m *Debug) String() string

func (*Debug) XXX_DiscardUnknown

func (m *Debug) XXX_DiscardUnknown()

func (*Debug) XXX_Marshal

func (m *Debug) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Debug) XXX_Merge

func (dst *Debug) XXX_Merge(src proto.Message)

func (*Debug) XXX_Size

func (m *Debug) XXX_Size() int

func (*Debug) XXX_Unmarshal

func (m *Debug) XXX_Unmarshal(b []byte) error

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger is an interface for a type that is made to log debug info.

func NewDelayLogger

func NewDelayLogger(delay time.Duration) Logger

NewDelayLogger returns a logger that sleeps after every log. This is useful for debugging infinite loops.

func NewLineLogger

func NewLineLogger() Logger

NewLineLogger returns a logger that logs the line at which the Printf method was called to stderr.

type Node

type Node struct {
	Label    string
	Children Nodes
}

Node is a type that represents a node in a tree. It has a label an children nodes.

func Field

func Field(name string, value string) Node

Field is a helper function for creating a Node with a label and one child label. This is how a field with a value is typically represented.

func Nested

func Nested(name string, fs ...Node) Node

Nested is a helper function for creating a Node.

func (Node) Equal

func (this Node) Equal(that Node) bool

Equal returns whether two Nodes are the same.

func (Node) String

func (this Node) String() string

String returns a string representation of Node.

type Nodes

type Nodes []Node

Nodes is a list of Node.

func RandomWalk

func RandomWalk(p parser.Interface, r Rand, next, down int) Nodes

RandomWalk does a random walk of the parser, given two probabilities.

next is passed to r.Intn and when a zero value is returned the Next method on the parser is called.
down is passed to r.Intn and when a non zero value is returned the Down method on the parser is called.

RandomWalk is great for testing that the implemented parser can handle random skipping of parts of the tree.

func Walk

func Walk(p parser.Interface) Nodes

Walk walks through the whole parser in a top down manner and records the values into a Nodes structute.

func (Nodes) Equal

func (this Nodes) Equal(that Nodes) bool

Equal returns whether two Node lists are equal.

func (Nodes) String

func (this Nodes) String() string

String returns a string representation of Nodes.

type Rand

type Rand interface {
	Intn(n int) int
}

Rand is a subset of the interface that is implemented by math/rand representing only the methods used by the RandomWalk function.

func NewRand

func NewRand() Rand

NewRand returns a random integer generator, that can be used with RandomWalk. Its seed is the current time.

Directories

Path Synopsis
Command debug-gen generates some of the code in the debug package.
Command debug-gen generates some of the code in the debug package.

Jump to

Keyboard shortcuts

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