ast

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgumentPairExpression added in v0.1.8

type ArgumentPairExpression struct {
	*BaseNode
	Key   Expression
	Value Expression
}

PairExpression represents a key/value pair in method parameters or arguments

func (*ArgumentPairExpression) String added in v0.1.8

func (ape *ArgumentPairExpression) String() string

String .....

func (*ArgumentPairExpression) TokenLiteral added in v0.1.8

func (ape *ArgumentPairExpression) TokenLiteral() string

TokenLiteral .....

type ArrayExpression

type ArrayExpression struct {
	*BaseNode
	Elements []Expression
}

ArrayExpression defines the array expression literal which contains the node expression and its value

func (*ArrayExpression) IsArrayExpression added in v0.1.8

func (ae *ArrayExpression) IsArrayExpression(t *testing.T) *TestableArrayExpression

IsArrayExpression returns pointer of the receiver array expression

func (*ArrayExpression) String

func (ae *ArrayExpression) String() string

ArrayExpression.String gets the string format of the Array type token

func (*ArrayExpression) TokenLiteral

func (ae *ArrayExpression) TokenLiteral() string

ArrayExpression gets the literal of the Array type token

type AssignExpression added in v0.1.0

type AssignExpression struct {
	*BaseNode
	Variables []Expression
	Value     Expression
	// Optioned attribute is only used when infix expression is local assignment in params.
	// For example: `foo(x = 10)`'s `x = 10` is an optioned assign expression
	// TODO: Remove this when we can put metadata inside bytecode.
	Optioned int
}

AssignExpression represents variable assignment in Goby.

func (*AssignExpression) IsAssignExpression added in v0.1.8

func (ae *AssignExpression) IsAssignExpression(t *testing.T) *TestableAssignExpression

IsAssignExpression returns pointer of the receiver assign expression

func (*AssignExpression) String added in v0.1.0

func (ae *AssignExpression) String() string

func (*AssignExpression) TokenLiteral added in v0.1.0

func (ae *AssignExpression) TokenLiteral() string

type BaseNode added in v0.1.0

type BaseNode struct {
	Token token.Token
	// contains filtered or unexported fields
}

BaseNode holds the attribute every expression or statement should have

func (*BaseNode) IsArrayExpression added in v0.1.8

func (b *BaseNode) IsArrayExpression(t *testing.T) *TestableArrayExpression

IsAssignExpression fails the test and returns nil by default

func (*BaseNode) IsAssignExpression added in v0.1.8

func (b *BaseNode) IsAssignExpression(t *testing.T) (ae *TestableAssignExpression)

IsAssignExpression fails the test and returns nil by default

func (*BaseNode) IsBooleanExpression added in v0.1.8

func (b *BaseNode) IsBooleanExpression(t *testing.T) (ae *TestableBooleanExpression)

IsBooleanExpression fails the test and returns nil by default

func (*BaseNode) IsCallExpression added in v0.1.8

func (b *BaseNode) IsCallExpression(t *testing.T) (ce *TestableCallExpression)

IsCallExpression fails the test and returns nil by default

func (*BaseNode) IsClassStmt added in v0.1.8

func (b *BaseNode) IsClassStmt(t *testing.T) *TestableClassStatement

IsClassStmt fails the test and returns nil by default

func (*BaseNode) IsConditionalExpression added in v0.1.8

func (b *BaseNode) IsConditionalExpression(t *testing.T) *TestableConditionalExpression

IsConditionalExpression fails the test and returns nil by default

func (*BaseNode) IsConstant added in v0.1.8

func (b *BaseNode) IsConstant(t *testing.T) (c *TestableConstant)

IsConstant fails the test and returns nil by default

func (*BaseNode) IsDefStmt added in v0.1.8

func (b *BaseNode) IsDefStmt(t *testing.T) *TestableDefStatement

IsDefStmt fails the test and returns nil by default

func (*BaseNode) IsExp added in v0.1.0

func (b *BaseNode) IsExp() bool

IsExp returns if current node should be considered as an expression

func (*BaseNode) IsExpression added in v0.1.8

func (b *BaseNode) IsExpression(t *testing.T) (te TestableExpression)

IsExpression fails the test and returns nil by default

func (*BaseNode) IsHashExpression added in v0.1.8

func (b *BaseNode) IsHashExpression(t *testing.T) *TestableHashExpression

HashExpression fails the test and returns nil by default

func (*BaseNode) IsIdentifier added in v0.1.8

func (b *BaseNode) IsIdentifier(t *testing.T) *TestableIdentifier

IsIdentifier fails the test and returns nil by default

func (*BaseNode) IsIfExpression added in v0.1.8

func (b *BaseNode) IsIfExpression(t *testing.T) *TestableIfExpression

IsIfExpression fails the test and returns nil by default

func (*BaseNode) IsInfixExpression added in v0.1.8

func (b *BaseNode) IsInfixExpression(t *testing.T) (ie *TestableInfixExpression)

IsInfixExpression fails the test and returns nil by default

func (*BaseNode) IsInstanceVariable added in v0.1.8

func (b *BaseNode) IsInstanceVariable(t *testing.T) (ie *TestableInstanceVariable)

IsInstanceVariable fails the test and returns nil by default

func (*BaseNode) IsIntegerLiteral added in v0.1.8

func (b *BaseNode) IsIntegerLiteral(t *testing.T) (il *TestableIntegerLiteral)

IsIntegerLiteral fails the test and returns nil by default

func (*BaseNode) IsModuleStmt added in v0.1.8

func (b *BaseNode) IsModuleStmt(t *testing.T) *TestableModuleStatement

IsModuleStmt fails the test and returns nil by default

func (*BaseNode) IsReturnStmt added in v0.1.8

func (b *BaseNode) IsReturnStmt(t *testing.T) *TestableReturnStatement

IsReturnStmt fails the test and returns nil by default

func (*BaseNode) IsSelfExpression added in v0.1.8

func (b *BaseNode) IsSelfExpression(t *testing.T) (sl *TestableSelfExpression)

IsSelfExpression fails the test and returns nil by default

func (*BaseNode) IsStmt added in v0.1.0

func (b *BaseNode) IsStmt() bool

IsStmt returns if current node should be considered as a statement

func (*BaseNode) IsStringLiteral added in v0.1.8

func (b *BaseNode) IsStringLiteral(t *testing.T) *TestableStringLiteral

IsStringLiteral fails the test and returns nil by default

func (*BaseNode) IsWhileStmt added in v0.1.8

func (b *BaseNode) IsWhileStmt(t *testing.T) (ws *TestableWhileStatement)

IsWhileStmt fails the test and returns nil by default

func (*BaseNode) IsYieldExpression added in v0.1.8

func (b *BaseNode) IsYieldExpression(t *testing.T) *TestableYieldExpression

IsYieldExpression returns pointer of the receiver yield expression

func (*BaseNode) Line added in v0.1.0

func (b *BaseNode) Line() int

Line returns node's token's line number

func (*BaseNode) MarkAsExp added in v0.1.0

func (b *BaseNode) MarkAsExp()

MarkAsExp marks current node to be expression

func (*BaseNode) MarkAsStmt added in v0.1.0

func (b *BaseNode) MarkAsStmt()

MarkAsStmt marks current node to be statement

type BlockStatement

type BlockStatement struct {
	*BaseNode
	Statements []Statement
}

func (*BlockStatement) IsEmpty added in v0.1.3

func (bs *BlockStatement) IsEmpty() bool

func (*BlockStatement) KeepLastValue added in v0.1.0

func (bs *BlockStatement) KeepLastValue()

KeepLastValue prevents block's last expression statement to be popped.

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

type BooleanExpression

type BooleanExpression struct {
	*BaseNode
	Value bool
}

BooleanExpression defines the boolean expression literal which contains the node expression and its value

func (*BooleanExpression) IsBooleanExpression added in v0.1.8

func (be *BooleanExpression) IsBooleanExpression(t *testing.T) *TestableBooleanExpression

IsBooleanExpression returns pointer of the receiver boolean expression

func (*BooleanExpression) String

func (b *BooleanExpression) String() string

BooleanExpression.String gets the string format of the Boolean type token

func (*BooleanExpression) TokenLiteral

func (b *BooleanExpression) TokenLiteral() string

BooleanExpression.TokenLiteral gets the literal of the Boolean type token

type BreakStatement added in v0.1.0

type BreakStatement struct {
	*BaseNode
}

BreakStatement represents "break" keyword

func (*BreakStatement) String added in v0.1.0

func (bs *BreakStatement) String() string

func (*BreakStatement) TokenLiteral added in v0.1.0

func (bs *BreakStatement) TokenLiteral() string

TokenLiteral returns token's literal

type CallExpression

type CallExpression struct {
	*BaseNode
	Receiver       Expression
	Method         string
	Arguments      []Expression
	Block          *BlockStatement
	BlockArguments []*Identifier
}

func (*CallExpression) IsCallExpression added in v0.1.8

func (ce *CallExpression) IsCallExpression(t *testing.T) *TestableCallExpression

IsCallExpression returns pointer of the receiver call expression

func (*CallExpression) String

func (tce *CallExpression) String() string

func (*CallExpression) TokenLiteral

func (tce *CallExpression) TokenLiteral() string

type ClassStatement

type ClassStatement struct {
	*BaseNode
	Name           *Constant
	Body           *BlockStatement
	SuperClass     Expression
	SuperClassName string
}

func (*ClassStatement) IsClassStmt added in v0.1.8

func (cs *ClassStatement) IsClassStmt(t *testing.T) *TestableClassStatement

func (*ClassStatement) String

func (cs *ClassStatement) String() string

func (*ClassStatement) TokenLiteral

func (cs *ClassStatement) TokenLiteral() string

type CodeBlock added in v0.1.8

type CodeBlock []TestableStatement

func (CodeBlock) NthStmt added in v0.1.8

func (cb CodeBlock) NthStmt(n int) TestableStatement

type ConditionalExpression added in v0.1.0

type ConditionalExpression struct {
	*BaseNode
	Condition   Expression
	Consequence *BlockStatement
}

ConditionalExpression represents if or elsif expression

func (*ConditionalExpression) IsConditionalExpression added in v0.1.8

func (ce *ConditionalExpression) IsConditionalExpression(t *testing.T) *TestableConditionalExpression

IsConditionalExpression returns pointer of the receiver conditional expression

func (*ConditionalExpression) String added in v0.1.0

func (ce *ConditionalExpression) String() string

func (*ConditionalExpression) TokenLiteral added in v0.1.0

func (ce *ConditionalExpression) TokenLiteral() string

TokenLiteral returns `if` or `elsif`

type Constant

type Constant struct {
	*BaseNode
	Value       string
	IsNamespace bool
}

func (*Constant) IsConstant added in v0.1.8

func (c *Constant) IsConstant(t *testing.T) *TestableConstant

IsConstant returns pointer of the current receiver constant

func (*Constant) ReturnValue

func (c *Constant) ReturnValue() string

func (*Constant) String

func (c *Constant) String() string

func (*Constant) TokenLiteral

func (c *Constant) TokenLiteral() string

type DefStatement

type DefStatement struct {
	*BaseNode
	Name           *Identifier
	Receiver       Expression
	Parameters     []Expression
	BlockStatement *BlockStatement
}

func (*DefStatement) IsDefStmt added in v0.1.8

func (ds *DefStatement) IsDefStmt(t *testing.T) *TestableDefStatement

IsDefStmt returns a pointer of the DefStatement

func (*DefStatement) String

func (tds *DefStatement) String() string

func (*DefStatement) TokenLiteral

func (tds *DefStatement) TokenLiteral() string

type Expression

type Expression interface {
	// contains filtered or unexported methods
}

type ExpressionStatement

type ExpressionStatement struct {
	*BaseNode
	Expression Expression
}

func (*ExpressionStatement) IsExpression added in v0.1.8

func (ts *ExpressionStatement) IsExpression(t *testing.T) TestableExpression

IsExpressionStmt returns ExpressionStatement itself

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

type FloatLiteral added in v0.1.6

type FloatLiteral struct {
	*BaseNode
	Value float64
}

FloatLiteral contains the node expression and its value

func (*FloatLiteral) String added in v0.1.6

func (il *FloatLiteral) String() string

FloatLiteral.String gets the string format of the Float type token

func (*FloatLiteral) TokenLiteral added in v0.1.6

func (il *FloatLiteral) TokenLiteral() string

FloatLiteral.TokenLiteral gets the literal of the Float type token

type GetBlockExpression added in v0.1.7

type GetBlockExpression struct {
	*BaseNode
}

GetBlockExpression represents `get_block` call in the AST

func (*GetBlockExpression) String added in v0.1.7

func (gbe *GetBlockExpression) String() string

String ...

func (*GetBlockExpression) TokenLiteral added in v0.1.7

func (gbe *GetBlockExpression) TokenLiteral() string

TokenLiteral ...

type HashExpression

type HashExpression struct {
	*BaseNode
	Data map[string]Expression
}

HashExpression defines the hash expression literal which contains the node expression and its value

func (*HashExpression) IsHashExpression added in v0.1.8

func (he *HashExpression) IsHashExpression(t *testing.T) *TestableHashExpression

IsHashExpression returns pointer of the receiver hash expression

func (*HashExpression) String

func (he *HashExpression) String() string

HashExpression.String gets the string format of the Hash type token

func (*HashExpression) TokenLiteral

func (he *HashExpression) TokenLiteral() string

HashExpression.TokenLiteral gets the literal of the Hash type token

type Identifier

type Identifier struct {
	*BaseNode
	Value string
}

func (*Identifier) IsIdentifier added in v0.1.8

func (i *Identifier) IsIdentifier(t *testing.T) *TestableIdentifier

IsIdentifier returns pointer of the receiver identifier

func (*Identifier) ReturnValue

func (i *Identifier) ReturnValue() string

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

type IfExpression

type IfExpression struct {
	*BaseNode
	Conditionals []*ConditionalExpression
	Alternative  *BlockStatement
}

func (*IfExpression) IsIfExpression added in v0.1.8

func (ie *IfExpression) IsIfExpression(t *testing.T) *TestableIfExpression

IsIfExpression returns pointer of the receiver if expression

func (*IfExpression) String

func (ie *IfExpression) String() string

func (*IfExpression) TokenLiteral

func (ie *IfExpression) TokenLiteral() string

type InfixExpression

type InfixExpression struct {
	*BaseNode
	Left     Expression
	Operator string
	Right    Expression
}

func (*InfixExpression) IsInfixExpression added in v0.1.8

func (ie *InfixExpression) IsInfixExpression(t *testing.T) *TestableInfixExpression

IsInfixExpression returns pointer of the receiver infix expression

func (*InfixExpression) String

func (ie *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (ie *InfixExpression) TokenLiteral() string

type InstanceVariable

type InstanceVariable struct {
	*BaseNode
	Value string
}

func (*InstanceVariable) IsInstanceVariable added in v0.1.8

func (iv *InstanceVariable) IsInstanceVariable(t *testing.T) *TestableInstanceVariable

IsInstanceVariable returns pointer of the receiver instance variable

func (*InstanceVariable) ReturnValue

func (iv *InstanceVariable) ReturnValue() string

func (*InstanceVariable) String

func (iv *InstanceVariable) String() string

func (*InstanceVariable) TokenLiteral

func (iv *InstanceVariable) TokenLiteral() string

type IntegerLiteral

type IntegerLiteral struct {
	*BaseNode
	Value int
}

IntegerLiteral contains the node expression and its value

func (*IntegerLiteral) IsIntegerLiteral added in v0.1.8

func (il *IntegerLiteral) IsIntegerLiteral(t *testing.T) *TestableIntegerLiteral

IsIntegerLiteral returns pointer of the receiver integer literal

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

IntegerLiteral.String gets the string format of the Integer type token

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

IntegerLiteral.TokenLiteral gets the Integer type token

type ModuleStatement

type ModuleStatement struct {
	*BaseNode
	Name       *Constant
	Body       *BlockStatement
	SuperClass *Constant
}

ModuleStatement represents module node in AST

func (*ModuleStatement) IsModuleStmt added in v0.1.8

func (ms *ModuleStatement) IsModuleStmt(t *testing.T) *TestableModuleStatement

IsModuleStmt returns a pointer of the module statement

func (*ModuleStatement) String

func (ms *ModuleStatement) String() string

func (*ModuleStatement) TokenLiteral

func (ms *ModuleStatement) TokenLiteral() string

TokenLiteral returns token's literal

type MultiVariableExpression added in v0.1.0

type MultiVariableExpression struct {
	*BaseNode
	Variables []Expression
}

MultiVariableExpression is not really an expression, it's just a container that holds multiple Variables

func (*MultiVariableExpression) String added in v0.1.0

func (m *MultiVariableExpression) String() string

func (*MultiVariableExpression) TokenLiteral added in v0.1.0

func (m *MultiVariableExpression) TokenLiteral() string

type NextStatement

type NextStatement struct {
	*BaseNode
}

NextStatement represents "next" keyword

func (*NextStatement) String

func (ns *NextStatement) String() string

func (*NextStatement) TokenLiteral

func (ns *NextStatement) TokenLiteral() string

TokenLiteral returns token's literal

type NilExpression

type NilExpression struct {
	*BaseNode
}

NilExpression represents nil node

func (*NilExpression) String

func (n *NilExpression) String() string

String returns `nil`

func (*NilExpression) TokenLiteral

func (n *NilExpression) TokenLiteral() string

TokenLiteral returns `nil`

type PrefixExpression

type PrefixExpression struct {
	*BaseNode
	Operator string
	Right    Expression
}

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

type Program

type Program struct {
	Statements []Statement
}

Program is the root node of entire AST

func (*Program) FirstStmt added in v0.1.8

func (p *Program) FirstStmt() TestableStatement

FirstStmt returns program's first statement as a TestStatement

func (*Program) NthStmt added in v0.1.8

func (p *Program) NthStmt(nth int) TestableStatement

NthStmt returns program's nth statement as a TestStatement

func (*Program) String

func (p *Program) String() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

type RangeExpression

type RangeExpression struct {
	*BaseNode
	Start Expression
	End   Expression
}

RangeExpression defines the range expression literal which contains the node expression and its start/end value

func (*RangeExpression) String

func (re *RangeExpression) String() string

RangeExpression.String gets the string format of the Range type token

func (*RangeExpression) TokenLiteral

func (re *RangeExpression) TokenLiteral() string

RangeExpression.TokenLiteral gets the literal of the Range type token

type ReturnStatement

type ReturnStatement struct {
	*BaseNode
	ReturnValue Expression
}

func (*ReturnStatement) IsReturnStmt added in v0.1.8

func (rs *ReturnStatement) IsReturnStmt(t *testing.T) (trs *TestableReturnStatement)

IsDefStmt returns a pointer of the ReturnStatement

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

type SelfExpression

type SelfExpression struct {
	*BaseNode
}

func (*SelfExpression) IsSelfExpression added in v0.1.8

func (se *SelfExpression) IsSelfExpression(t *testing.T) *TestableSelfExpression

IsSelfExpression returns pointer of the receiver self expression

func (*SelfExpression) String

func (se *SelfExpression) String() string

func (*SelfExpression) TokenLiteral

func (se *SelfExpression) TokenLiteral() string

type Statement

type Statement interface {
	// contains filtered or unexported methods
}

type StringLiteral

type StringLiteral struct {
	*BaseNode
	Value string
}

StringLiteral contains the node expression and its value

func (*StringLiteral) IsStringLiteral added in v0.1.8

func (sl *StringLiteral) IsStringLiteral(t *testing.T) *TestableStringLiteral

IsStringLiteral returns pointer of the receiver string literal

func (*StringLiteral) String

func (sl *StringLiteral) String() string

StringLiteral.String gets the string format of the String type token

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

StringLiteral.TokenLiteral gets the literal of the String type token

type TestableArrayExpression added in v0.1.8

type TestableArrayExpression struct {
	*ArrayExpression
	// contains filtered or unexported fields
}

TestableArrayExpression

func (*TestableArrayExpression) TestableElements added in v0.1.8

func (tae *TestableArrayExpression) TestableElements() (tes []TestableExpression)

TestableElements returns array expression's element nodes and assert them as TestableExpression

type TestableAssignExpression added in v0.1.8

type TestableAssignExpression struct {
	*AssignExpression
	// contains filtered or unexported fields
}

TestableAssignExpression

func (*TestableAssignExpression) NthVariable added in v0.1.8

func (tae *TestableAssignExpression) NthVariable(n int) TestableExpression

NthVariable returns the nth variable of the assignment as a TestableExpression

func (*TestableAssignExpression) TestableValue added in v0.1.8

func (tae *TestableAssignExpression) TestableValue() TestableExpression

TestableValue returns the assignment's value as a TestableExpression

type TestableBooleanExpression added in v0.1.8

type TestableBooleanExpression struct {
	*BooleanExpression
	// contains filtered or unexported fields
}

TestableBooleanExpression

func (*TestableBooleanExpression) ShouldEqualTo added in v0.1.8

func (tbe *TestableBooleanExpression) ShouldEqualTo(expected bool)

ShouldEqualTo compares if the boolean expression's value equals to the expected value

type TestableCallExpression added in v0.1.8

type TestableCallExpression struct {
	*CallExpression
	// contains filtered or unexported fields
}

TestableCallExpression

func (*TestableCallExpression) NthArgument added in v0.1.8

func (tce *TestableCallExpression) NthArgument(n int) TestableExpression

NthArgument returns n-th argument of the call expression as TestingExpression

func (*TestableCallExpression) ShouldHasMethodName added in v0.1.8

func (tce *TestableCallExpression) ShouldHasMethodName(expectedName string)

ShouldHasMethodName checks if the method's name is same as we expected

func (*TestableCallExpression) ShouldHasNumbersOfArguments added in v0.1.8

func (tce *TestableCallExpression) ShouldHasNumbersOfArguments(n int)

ShouldHasNumbersOfArguments checks if the method call's argument number is same we expected

func (*TestableCallExpression) TestableReceiver added in v0.1.8

func (tce *TestableCallExpression) TestableReceiver() TestableExpression

ReceiverExpression returns call expression's receiver as TestingExpression

type TestableClassStatement added in v0.1.8

type TestableClassStatement struct {
	*ClassStatement
	// contains filtered or unexported fields
}

func (*TestableClassStatement) HasMethod added in v0.1.8

func (tcs *TestableClassStatement) HasMethod(methodName string) (ds *TestableDefStatement)

HasMethod checks if current class statement has target method, and returns the method if it has

func (*TestableClassStatement) ShouldHasName added in v0.1.8

func (tcs *TestableClassStatement) ShouldHasName(name string)

func (*TestableClassStatement) ShouldInherits added in v0.1.8

func (tcs *TestableClassStatement) ShouldInherits(className string)

ShouldInherits checks if current class statement inherits the target class

type TestableConditionalExpression added in v0.1.8

type TestableConditionalExpression struct {
	*ConditionalExpression
	// contains filtered or unexported fields
}

TestableConditionalExpression

func (*TestableConditionalExpression) TestableCondition added in v0.1.8

func (tce *TestableConditionalExpression) TestableCondition() TestableExpression

func (*TestableConditionalExpression) TestableConsequence added in v0.1.8

func (tce *TestableConditionalExpression) TestableConsequence() CodeBlock

type TestableConstant added in v0.1.8

type TestableConstant struct {
	*Constant
	// contains filtered or unexported fields
}

TestableConstant

func (*TestableConstant) ShouldHasName added in v0.1.8

func (tc *TestableConstant) ShouldHasName(expectedName string)

ShouldHasName checks if the constant's name is same as we expected

type TestableDefStatement added in v0.1.8

type TestableDefStatement struct {
	*DefStatement
	// contains filtered or unexported fields
}

func (*TestableDefStatement) MethodBody added in v0.1.8

func (tds *TestableDefStatement) MethodBody() CodeBlock

MethodBody returns method body's statements and assert them as TestingStatements

func (*TestableDefStatement) ShouldHasName added in v0.1.8

func (tds *TestableDefStatement) ShouldHasName(expectedName string)

ShouldHasName checks if the method's name is what we expected

func (*TestableDefStatement) ShouldHasNoParam added in v0.1.8

func (tds *TestableDefStatement) ShouldHasNoParam()

ShouldHasNoParam checks if the method has no param

func (*TestableDefStatement) ShouldHasNormalParam added in v0.1.8

func (tds *TestableDefStatement) ShouldHasNormalParam(expectedName string)

ShouldHasNormalParam checks if the method has expected normal argument

func (*TestableDefStatement) ShouldHasOptionalKeywordParam added in v0.1.8

func (tds *TestableDefStatement) ShouldHasOptionalKeywordParam(expectedName string)

ShouldHasOptionalKeywordParam checks if the method has expected optional keyword argument

func (*TestableDefStatement) ShouldHasOptionalParam added in v0.1.8

func (tds *TestableDefStatement) ShouldHasOptionalParam(expectedName string)

ShouldHasOptionalParam checks if the method has expected optional argument

func (*TestableDefStatement) ShouldHasRequiredKeywordParam added in v0.1.8

func (tds *TestableDefStatement) ShouldHasRequiredKeywordParam(expectedName string)

ShouldHasRequiredKeywordParam checks if the method has expected keyword argument

func (*TestableDefStatement) ShouldHasSplatParam added in v0.1.8

func (tds *TestableDefStatement) ShouldHasSplatParam(expectedName string)

ShouldHasSplatParam checks if the method has expected splat argument

type TestableExpression added in v0.1.8

type TestableExpression interface {
	Expression
	// Test Helpers
	IsArrayExpression(t *testing.T) *TestableArrayExpression
	IsAssignExpression(t *testing.T) *TestableAssignExpression
	IsBooleanExpression(t *testing.T) *TestableBooleanExpression
	IsCallExpression(t *testing.T) *TestableCallExpression
	IsConditionalExpression(t *testing.T) *TestableConditionalExpression
	IsConstant(t *testing.T) *TestableConstant
	IsHashExpression(t *testing.T) *TestableHashExpression
	IsIdentifier(t *testing.T) *TestableIdentifier
	IsIfExpression(t *testing.T) *TestableIfExpression
	IsInfixExpression(t *testing.T) *TestableInfixExpression
	IsInstanceVariable(t *testing.T) *TestableInstanceVariable
	IsIntegerLiteral(t *testing.T) *TestableIntegerLiteral
	IsSelfExpression(t *testing.T) *TestableSelfExpression
	IsStringLiteral(t *testing.T) *TestableStringLiteral
	IsYieldExpression(t *testing.T) *TestableYieldExpression
}

TestableExpression interface implements basic Expression's functions, and helper functions to assert node's type

type TestableHashExpression added in v0.1.8

type TestableHashExpression struct {
	*HashExpression
	// contains filtered or unexported fields
}

TestableHashExpression

func (*TestableHashExpression) TestableDataPairs added in v0.1.8

func (the *TestableHashExpression) TestableDataPairs() (pairs map[string]TestableExpression)

TestableDataPairs returns a map of hash expression's element and assert them as TestableExpression

type TestableIdentifier added in v0.1.8

type TestableIdentifier struct {
	*Identifier
	// contains filtered or unexported fields
}

TestableIdentifier

func (*TestableIdentifier) ShouldHasName added in v0.1.8

func (ti *TestableIdentifier) ShouldHasName(expectedName string)

ShouldHasName checks if the identifier's name is same as we expected

type TestableIdentifierValue added in v0.1.8

type TestableIdentifierValue string

TestableIdentifierValue for marking a string as an identifier's value for test

type TestableIfExpression added in v0.1.8

type TestableIfExpression struct {
	*IfExpression
	// contains filtered or unexported fields
}

TestableIfExpression

func (*TestableIfExpression) ShouldHasNumberOfConditionals added in v0.1.8

func (tie *TestableIfExpression) ShouldHasNumberOfConditionals(n int)

func (*TestableIfExpression) TestableAlternative added in v0.1.8

func (tie *TestableIfExpression) TestableAlternative() CodeBlock

TestableAlternative returns if expression's alternative code block as TestableExpression

func (*TestableIfExpression) TestableConditionals added in v0.1.8

func (tie *TestableIfExpression) TestableConditionals() (tes []TestableExpression)

TestableConditionals returns if expression's conditionals and assert them as TestableExpression

type TestableInfixExpression added in v0.1.8

type TestableInfixExpression struct {
	*InfixExpression
	// contains filtered or unexported fields
}

TestableInfixExpression

func (*TestableInfixExpression) ShouldHasOperator added in v0.1.8

func (tie *TestableInfixExpression) ShouldHasOperator(expectedOperator string)

ShouldHasOperator checks if the infix expression has expected operator

func (*TestableInfixExpression) TestableLeftExpression added in v0.1.8

func (tie *TestableInfixExpression) TestableLeftExpression() TestableExpression

LeftExpression returns infix expression's left expression as TestingExpression

func (*TestableInfixExpression) TestableRightExpression added in v0.1.8

func (tie *TestableInfixExpression) TestableRightExpression() TestableExpression

RightExpression returns infix expression's right expression as TestingExpression

type TestableInstanceVariable added in v0.1.8

type TestableInstanceVariable struct {
	*InstanceVariable
	// contains filtered or unexported fields
}

TestableInstanceVariable

func (*TestableInstanceVariable) ShouldHasName added in v0.1.8

func (tiv *TestableInstanceVariable) ShouldHasName(expectedName string)

ShouldHasName checks if the instance variable's name is same as we expected

type TestableIntegerLiteral added in v0.1.8

type TestableIntegerLiteral struct {
	*IntegerLiteral
	// contains filtered or unexported fields
}

TestableIntegerLiteral

func (*TestableIntegerLiteral) ShouldEqualTo added in v0.1.8

func (til *TestableIntegerLiteral) ShouldEqualTo(expectedInt int)

ShouldEqualTo compares if the integer literal's value equals to the expected value

type TestableModuleStatement added in v0.1.8

type TestableModuleStatement struct {
	*ModuleStatement
	// contains filtered or unexported fields
}

func (*TestableModuleStatement) HasMethod added in v0.1.8

func (tms *TestableModuleStatement) HasMethod(t *testing.T, methodName string) (ds *TestableDefStatement)

HasMethod checks if current class statement has target method, and returns the method if it has

func (*TestableModuleStatement) ShouldHasName added in v0.1.8

func (tms *TestableModuleStatement) ShouldHasName(name string)

type TestableReturnStatement added in v0.1.8

type TestableReturnStatement struct {
	*ReturnStatement
	// contains filtered or unexported fields
}

func (*TestableReturnStatement) ShouldHasValue added in v0.1.8

func (trs *TestableReturnStatement) ShouldHasValue(value interface{})

type TestableSelfExpression added in v0.1.8

type TestableSelfExpression struct {
	*SelfExpression
	// contains filtered or unexported fields
}

TestableSelfExpression

type TestableStatement added in v0.1.8

type TestableStatement interface {
	Statement
	// Test Helpers
	IsClassStmt(t *testing.T) *TestableClassStatement
	IsDefStmt(t *testing.T) *TestableDefStatement
	IsExpression(t *testing.T) TestableExpression
	IsModuleStmt(t *testing.T) *TestableModuleStatement
	IsReturnStmt(t *testing.T) *TestableReturnStatement
	IsWhileStmt(t *testing.T) *TestableWhileStatement
}

type TestableStringLiteral added in v0.1.8

type TestableStringLiteral struct {
	*StringLiteral
	// contains filtered or unexported fields
}

TestableStringLiteral

func (*TestableStringLiteral) ShouldEqualTo added in v0.1.8

func (tsl *TestableStringLiteral) ShouldEqualTo(expected string)

ShouldEqualTo compares if the string literal's value equals to the expected value

type TestableWhileStatement added in v0.1.8

type TestableWhileStatement struct {
	*WhileStatement
	// contains filtered or unexported fields
}

func (*TestableWhileStatement) CodeBlock added in v0.1.8

func (tws *TestableWhileStatement) CodeBlock() CodeBlock

Block returns while statement's code block as a set of TestingStatements

func (*TestableWhileStatement) ConditionExpression added in v0.1.8

func (tws *TestableWhileStatement) ConditionExpression() TestableExpression

ConditionExpression returns while statement's condition as TestingExpression

type TestableYieldExpression added in v0.1.8

type TestableYieldExpression struct {
	*YieldExpression
	// contains filtered or unexported fields
}

TestableYieldExpression

func (*TestableYieldExpression) NthArgument added in v0.1.8

func (tye *TestableYieldExpression) NthArgument(n int) TestableExpression

NthArgument returns n-th argument of the yield expression as TestingExpression

type Variable added in v0.1.0

type Variable interface {
	ReturnValue() string
	Expression
	// contains filtered or unexported methods
}

Variable interface represents assignable nodes in Goby, currently are Identifier, InstanceVariable and Constant

type WhileStatement

type WhileStatement struct {
	*BaseNode
	Condition Expression
	Body      *BlockStatement
}

func (*WhileStatement) IsWhileStmt added in v0.1.8

func (ws *WhileStatement) IsWhileStmt(t *testing.T) *TestableWhileStatement

IsWhileStmt returns the pointer of current while statement

func (*WhileStatement) String

func (ws *WhileStatement) String() string

func (*WhileStatement) TokenLiteral

func (ws *WhileStatement) TokenLiteral() string

type YieldExpression

type YieldExpression struct {
	*BaseNode
	Arguments []Expression
}

func (*YieldExpression) IsYieldExpression added in v0.1.8

func (ye *YieldExpression) IsYieldExpression(t *testing.T) *TestableYieldExpression

IsYieldExpression returns pointer of the receiver yield expression

func (*YieldExpression) String

func (ye *YieldExpression) String() string

func (*YieldExpression) TokenLiteral

func (ye *YieldExpression) TokenLiteral() string

Jump to

Keyboard shortcuts

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