Documentation
¶
Index ¶
- Constants
- Variables
- func CheckParserErrors(t *testing.T, p ParserInterface)
- func DebugParser(t *testing.T, source string, parserFactory ParserFactory)
- func ExpectNoErrors() func(*TestContext)
- func ExpectProgram(expectedBodyLen int) func(*TestContext)
- func IsTestEnabled(tags []string) bool
- func MustCreateParser(source string) (ParserInterface, *TestContext)
- func QuickClass(name, body string) string
- func QuickFunction(name, params, body string) string
- func QuickPHP(code string) string
- func SetDefaultParserFactory(factory ParserFactory)
- func SetGlobalConfig(config *GlobalConfig)
- func ValidateClassConstant(expectedName string, expectedVisibility string) func(*ast.ClassExpression, *testing.T)
- func ValidateClassMethod(expectedName, expectedVisibility string) func(*ast.ClassExpression, *testing.T)
- func ValidateNumberArg(expectedValue string) func(ast.Node, *testing.T)
- func ValidateProperty(expectedName string, expectedVisibility string) func(*ast.ClassExpression, *testing.T)
- func ValidateStringArg(expectedValue, expectedRaw string) func(ast.Node, *testing.T)
- type ASTAssertions
- func (a *ASTAssertions) AssertArray(node ast.Node, expectedElementCount int) *ast.ArrayExpression
- func (a *ASTAssertions) AssertAssignment(node ast.Node, expectedOperator string) *ast.AssignmentExpression
- func (a *ASTAssertions) AssertBinaryExpression(node ast.Node, expectedOperator string) *ast.BinaryExpression
- func (a *ASTAssertions) AssertCallExpression(expr ast.Expression) *ast.CallExpression
- func (a *ASTAssertions) AssertCatchClausesCount(tryStmt *ast.TryStatement, expectedCount int)
- func (a *ASTAssertions) AssertClass(node ast.Node, expectedName string) *ast.ClassExpression
- func (a *ASTAssertions) AssertEchoStatement(stmt ast.Statement, expectedArgCount int) *ast.EchoStatement
- func (a *ASTAssertions) AssertExpressionStatement(stmt ast.Statement) *ast.ExpressionStatement
- func (a *ASTAssertions) AssertFullyQualifiedCall(callExpr *ast.CallExpression, expectedName string)
- func (a *ASTAssertions) AssertFunctionBody(funcDecl *ast.FunctionDeclaration, expectedStatements int)
- func (a *ASTAssertions) AssertFunctionDeclaration(stmt ast.Statement, expectedName string) *ast.FunctionDeclaration
- func (a *ASTAssertions) AssertGlobalNamespaceStatement(stmt ast.Statement) *ast.NamespaceStatement
- func (a *ASTAssertions) AssertIdentifier(node ast.Node, expectedName string) *ast.IdentifierNode
- func (a *ASTAssertions) AssertMatchExpression(expr ast.Expression) *ast.MatchExpression
- func (a *ASTAssertions) AssertMethodCall(node ast.Node, expectedObject, expectedMethod string) *ast.MethodCallExpression
- func (a *ASTAssertions) AssertNamespaceStatement(stmt ast.Statement, expectedName string) *ast.NamespaceStatement
- func (a *ASTAssertions) AssertNumberLiteral(node ast.Node, expectedValue string) *ast.NumberLiteral
- func (a *ASTAssertions) AssertProgramBody(program *ast.Program, expectedLength int) []ast.Statement
- func (a *ASTAssertions) AssertReturnStatement(stmt ast.Statement) *ast.ReturnStatement
- func (a *ASTAssertions) AssertStringLiteral(node ast.Node, expectedValue, expectedRaw string) *ast.StringLiteral
- func (a *ASTAssertions) AssertTernaryExpression(node ast.Node) *ast.TernaryExpression
- func (a *ASTAssertions) AssertTraitDeclaration(stmt ast.Statement, expectedName string) *ast.TraitDeclaration
- func (a *ASTAssertions) AssertTryBlockEmpty(tryStmt *ast.TryStatement)
- func (a *ASTAssertions) AssertTryBlockStatements(tryStmt *ast.TryStatement, expectedCount int)
- func (a *ASTAssertions) AssertTryStatement(stmt ast.Statement) *ast.TryStatement
- func (a *ASTAssertions) AssertVariable(node ast.Node, expectedName string) *ast.Variable
- type ArrayElement
- type BenchmarkBuilder
- type BenchmarkCase
- type CatchClause
- type EnumCase
- type ErrorTestBuilder
- type ErrorTestCase
- type ErrorTestSuite
- func (s *ErrorTestSuite) Add(testCase ErrorTestCase) *ErrorTestSuite
- func (s *ErrorTestSuite) AddError(name, source, errorKeyword string) *ErrorTestSuite
- func (s *ErrorTestSuite) AddRecovery(name, source string, recoverCount int) *ErrorTestSuite
- func (s *ErrorTestSuite) AddSuccess(name, source string) *ErrorTestSuite
- func (s *ErrorTestSuite) Run(t *testing.T)
- type GlobalConfig
- type InterpolationPart
- type MatchArm
- type PHPSourceBuilder
- func (b *PHPSourceBuilder) Add(code string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddClass(name, body string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddEcho(args ...string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddFor(init, condition, increment, body string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddFunction(name string, params []string, body string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddIf(condition, body string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddLine(code string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddTryCatch(tryBody, catchVar, catchBody string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddVariable(name, value string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) AddWhile(condition, body string) *PHPSourceBuilder
- func (b *PHPSourceBuilder) Build() string
- func (b *PHPSourceBuilder) String() string
- type ParserFactory
- type ParserInterface
- type ParserTestBuilder
- func (b *ParserTestBuilder) Test(t *testing.T, source string, validator func(*TestContext))
- func (b *ParserTestBuilder) TestTableDriven(t *testing.T, tests []struct{ ... })
- func (b *ParserTestBuilder) WithConfig(config *TestConfig) *ParserTestBuilder
- func (b *ParserTestBuilder) WithSetup(setup func(*TestContext)) *ParserTestBuilder
- func (b *ParserTestBuilder) WithStrictMode(strict bool) *ParserTestBuilder
- type ParserTester
- func (pt *ParserTester) Quick(source string, validator ValidationFunc)
- func (pt *ParserTester) QuickError(source, errorKeyword string)
- func (pt *ParserTester) QuickString(varName, value, raw string)
- func (pt *ParserTester) QuickSuccess(source string)
- func (pt *ParserTester) QuickVariable(varName, value string)
- type StringInterpolation
- type SwitchCase
- type TestCase
- type TestConfig
- type TestContext
- type TestDataItem
- type TestDataset
- type TestSuiteBuilder
- func (b *TestSuiteBuilder) Add(testCase TestCase) *TestSuiteBuilder
- func (b *TestSuiteBuilder) AddClass(name, className, classBody string, ...) *TestSuiteBuilder
- func (b *TestSuiteBuilder) AddControlFlow(name, flowType, source string, validators ...func(ast.Statement, *testing.T)) *TestSuiteBuilder
- func (b *TestSuiteBuilder) AddEcho(name string, args []string, validators ...func(ast.Node, *testing.T)) *TestSuiteBuilder
- func (b *TestSuiteBuilder) AddFunction(name, funcName string, params []string, ...) *TestSuiteBuilder
- func (b *TestSuiteBuilder) AddSimple(name, source string, validator ValidationFunc) *TestSuiteBuilder
- func (b *TestSuiteBuilder) AddStringAssignment(name, varName, value, raw string) *TestSuiteBuilder
- func (b *TestSuiteBuilder) AddVariableAssignment(name, varName, valueSource string) *TestSuiteBuilder
- func (b *TestSuiteBuilder) Only(testName string) *TestSuiteBuilder
- func (b *TestSuiteBuilder) Run(t *testing.T)
- func (b *TestSuiteBuilder) Skip(testName string) *TestSuiteBuilder
- func (b *TestSuiteBuilder) WithConfig(config *TestConfig) *TestSuiteBuilder
- type TypedParam
- type ValidationFunc
- func ValidateAbstractClass(className string) ValidationFunc
- func ValidateAbstractClassInExpressionStatement(className string) ValidationFunc
- func ValidateAdditionAssignment(varName string) ValidationFunc
- func ValidateAnonymousFunctionAssignment(varName string, bodyValidator ValidationFunc) ValidationFunc
- func ValidateAnonymousFunctionWithParams(varName string, params []string, bodyValidator ValidationFunc) ValidationFunc
- func ValidateArrayAccess(varName, arrayVar, index string) ValidationFunc
- func ValidateArrayAssignment(varName string, elements []ArrayElement) ValidationFunc
- func ValidateArrowFunctionAssignment(varName string, params []string, bodyValidator ValidationFunc) ValidationFunc
- func ValidateAssignment(varName, operator string) ValidationFunc
- func ValidateAssignmentExpression(varName, value string) ValidationFunc
- func ValidateAssignmentOperation(varName, operator, valueVar string) ValidationFunc
- func ValidateBackedEnum(enumName, backingType string, cases []EnumCase) ValidationFunc
- func ValidateBasicAssignment(varName string) ValidationFunc
- func ValidateBinaryAssignment(varName, leftVar, operator, rightVar string) ValidationFunc
- func ValidateBinaryExpression(leftVar, operator, rightValue string) ValidationFunc
- func ValidateBinaryOperation(operator string, leftValidator, rightValidator func(ast.Node, *testing.T)) ValidationFunc
- func ValidateBitwiseAndAssignment(varName string) ValidationFunc
- func ValidateBitwiseOrAssignment(varName string) ValidationFunc
- func ValidateBitwiseXorAssignment(varName string) ValidationFunc
- func ValidateBreakStatement() ValidationFunc
- func ValidateChainedArrayAccess(varName, arrayVar string, indices []string) ValidationFunc
- func ValidateChainedStaticCall(varName, className, firstMethod string, firstArgs []string, ...) ValidationFunc
- func ValidateClass(expectedName string, validators ...func(*ast.ClassExpression, *testing.T)) ValidationFunc
- func ValidateClassDeclaration(className, parentClass string, interfaces []string, ...) ValidationFunc
- func ValidateClassInExpressionStatement(className string) ValidationFunc
- func ValidateClassWithInheritance(className, parentClass string, memberValidator ValidationFunc) ValidationFunc
- func ValidateClassWithInterfaces(className string, interfaces []string) ValidationFunc
- func ValidateClosureWithUse(varName string, params []string, useVars []string, ...) ValidationFunc
- func ValidateCoalesceAssignment(varName string) ValidationFunc
- func ValidateCoalesceExpression(varName, leftVar, rightVar string) ValidationFunc
- func ValidateConcatenationAssignment(varName string) ValidationFunc
- func ValidateControlFlow(expectedType string, validators ...func(ast.Statement, *testing.T)) ValidationFunc
- func ValidateDivisionAssignment(varName string) ValidationFunc
- func ValidateEcho(expectedArgCount int, argValidators ...func(ast.Node, *testing.T)) ValidationFunc
- func ValidateEchoArgs(args []string) ValidationFunc
- func ValidateEchoVariable(varName string) ValidationFunc
- func ValidateEnumDeclaration(enumName, backingType string, cases []string) ValidationFunc
- func ValidateErrorMessage(expectedKeywords ...string) ValidationFunc
- func ValidateFinalClass(className string) ValidationFunc
- func ValidateFinalClassInExpressionStatement(className string) ValidationFunc
- func ValidateForStatement(initValidator, testValidator, updateValidator, bodyValidator ValidationFunc) ValidationFunc
- func ValidateForeachStatement(iterableVar, keyVar, valueVar string, bodyValidators ...ValidationFunc) ValidationFunc
- func ValidateFunction(expectedName string, expectedParamCount int, ...) ValidationFunc
- func ValidateFunctionCall(funcName string, args ...string) ValidationFunc
- func ValidateFunctionDeclaration(funcName string, params []string, returnType string, ...) ValidationFunc
- func ValidateFunctionWithIntersectionType(funcName, intersectionType, paramName string, bodyValidator ValidationFunc) ValidationFunc
- func ValidateFunctionWithNullableUnionType(funcName, nullableUnionType string, bodyValidator ValidationFunc) ValidationFunc
- func ValidateFunctionWithParameters(funcName string, params []string, bodyValidator ValidationFunc) ValidationFunc
- func ValidateFunctionWithReturnType(funcName string, returnType string, bodyValidator ValidationFunc) ValidationFunc
- func ValidateFunctionWithUnionType(funcName, unionType, paramName string, bodyValidator ValidationFunc) ValidationFunc
- func ValidateHeredocAssignment(varName, expectedValue string) ValidationFunc
- func ValidateIfElseStatement(testValidator ValidationFunc, consequentValidator ValidationFunc, ...) ValidationFunc
- func ValidateIfStatement(testValidator ValidationFunc, consequentValidators ...ValidationFunc) ValidationFunc
- func ValidateInstanceofExpression(varName, objectVar, className string) ValidationFunc
- func ValidateInterpolatedStringAssignment(varName string, interpolation StringInterpolation) ValidationFunc
- func ValidateLeftShiftAssignment(varName string) ValidationFunc
- func ValidateMatchExpression(varName, matchVar string, arms []MatchArm) ValidationFunc
- func ValidateMatchWithMultipleConditions(varName, matchVar string, arms []MatchArm) ValidationFunc
- func ValidateModuloAssignment(varName string) ValidationFunc
- func ValidateMultiplicationAssignment(varName string) ValidationFunc
- func ValidateNoErrors() ValidationFunc
- func ValidateNowdocAssignment(varName, expectedValue string) ValidationFunc
- func ValidatePostfixAssignment(varName, operandVar, operator string) ValidationFunc
- func ValidatePostfixExpression(varName, operator string) ValidationFunc
- func ValidatePowerAssignment(varName string) ValidationFunc
- func ValidatePrefixExpression(varName, operandVar, operator string) ValidationFunc
- func ValidatePropertyDeclaration(visibility, varName, typeName, defaultValue string) ValidationFunc
- func ValidateReturnBinaryExpression(leftVar, operator, rightVar string) ValidationFunc
- func ValidateReturnNull() ValidationFunc
- func ValidateReturnStatement(expectedValue string) ValidationFunc
- func ValidateReturnVariable(varName string) ValidationFunc
- func ValidateRightShiftAssignment(varName string) ValidationFunc
- func ValidateStaticConstantAccess(varName, className, constantName string) ValidationFunc
- func ValidateStaticMethodCall(varName, className, methodName string, args []string) ValidationFunc
- func ValidateStaticPropertyAccess(varName, className, propertyName string) ValidationFunc
- func ValidateStringAssignment(varName, expectedValue, expectedRaw string) ValidationFunc
- func ValidateSubtractionAssignment(varName string) ValidationFunc
- func ValidateSwitchStatement(discriminantVar string, cases []SwitchCase) ValidationFunc
- func ValidateTernaryExpression(varName, conditionVar, trueVar, falseVar string) ValidationFunc
- func ValidateTryCatchFinallyStatement(tryValidator ValidationFunc, catchValidator CatchClause, ...) ValidationFunc
- func ValidateTryCatchStatement(tryValidator ValidationFunc, catchValidator CatchClause) ValidationFunc
- func ValidateTryMultipleCatchStatement(tryValidator ValidationFunc, catchValidators []CatchClause) ValidationFunc
- func ValidateTypedArrowFunction(varName string, params []TypedParam, returnType string, ...) ValidationFunc
- func ValidateTypedFunction(funcName string, params []TypedParam, bodyValidator ValidationFunc) ValidationFunc
- func ValidateVariable(name string) ValidationFunc
- func ValidateVariableAssignment(varName string) ValidationFunc
- func ValidateVariableExpression(varName string) ValidationFunc
- func ValidateWhileStatement(testValidator ValidationFunc, bodyValidators ...ValidationFunc) ValidationFunc
Constants ¶
const ( CategoryBasic = "basic" CategoryExpressions = "expressions" CategoryStatements = "statements" CategoryClasses = "classes" CategoryFunctions = "functions" CategoryControlFlow = "control_flow" CategoryErrors = "errors" CategoryPHP8 = "php8" CategoryPHP81 = "php81" CategoryPHP82 = "php82" CategoryPHP83 = "php83" CategoryPHP84 = "php84" )
TestCategory 测试分类常量
const ( TagSmoke = "smoke" TagRegression = "regression" TagSlow = "slow" TagExperimental = "experimental" TagBenchmark = "benchmark" TagIntegration = "integration" TagUnit = "unit" TagError = "error" )
TestTags 测试标签常量
Variables ¶
var CreateDefaultParserFactory func() ParserFactory
CreateDefaultParserFactory 创建默认解析器工厂的辅助函数 这个函数需要在parser包中实现
var DefaultGlobalConfig = &GlobalConfig{ DefaultStrictMode: true, EnableDebug: false, TestDataDir: "testdata", GoldenFileDir: "testdata/golden", BenchmarkEnabled: true, CoverageEnabled: true, }
DefaultGlobalConfig 默认全局配置
Functions ¶
func CheckParserErrors ¶
func CheckParserErrors(t *testing.T, p ParserInterface)
CheckParserErrors 检查解析器错误 - 从原有代码迁移
func DebugParser ¶
func DebugParser(t *testing.T, source string, parserFactory ParserFactory)
DebugParser 调试解析器,输出详细信息
func ExpectProgram ¶
func ExpectProgram(expectedBodyLen int) func(*TestContext)
ExpectProgram 验证程序体长度
func MustCreateParser ¶
func MustCreateParser(source string) (ParserInterface, *TestContext)
MustCreateParser 必须创建解析器,失败则panic
func QuickFunction ¶
QuickFunction 快速创建函数的PHP源码
func SetDefaultParserFactory ¶
func SetDefaultParserFactory(factory ParserFactory)
SetDefaultParserFactory 设置默认解析器工厂
func ValidateClassConstant ¶
func ValidateClassConstant(expectedName string, expectedVisibility string) func(*ast.ClassExpression, *testing.T)
ValidateClassConstant 创建类常量验证器
func ValidateClassMethod ¶
func ValidateClassMethod(expectedName, expectedVisibility string) func(*ast.ClassExpression, *testing.T)
ValidateClassMethod 创建类方法验证器
func ValidateNumberArg ¶
ValidateNumberArg 创建数字参数验证器
func ValidateProperty ¶
func ValidateProperty(expectedName string, expectedVisibility string) func(*ast.ClassExpression, *testing.T)
ValidateProperty 创建类属性验证器
Types ¶
type ASTAssertions ¶
type ASTAssertions struct {
// contains filtered or unexported fields
}
ASTAssertions 提供AST特定的断言
func NewASTAssertions ¶
func NewASTAssertions(t *testing.T) *ASTAssertions
NewASTAssertions 创建AST断言工具
func (*ASTAssertions) AssertArray ¶
func (a *ASTAssertions) AssertArray(node ast.Node, expectedElementCount int) *ast.ArrayExpression
AssertArray 断言数组表达式
func (*ASTAssertions) AssertAssignment ¶
func (a *ASTAssertions) AssertAssignment(node ast.Node, expectedOperator string) *ast.AssignmentExpression
AssertAssignment 断言赋值表达式
func (*ASTAssertions) AssertBinaryExpression ¶
func (a *ASTAssertions) AssertBinaryExpression(node ast.Node, expectedOperator string) *ast.BinaryExpression
AssertBinaryExpression 断言二元表达式
func (*ASTAssertions) AssertCallExpression ¶
func (a *ASTAssertions) AssertCallExpression(expr ast.Expression) *ast.CallExpression
AssertCallExpression 断言函数调用表达式
func (*ASTAssertions) AssertCatchClausesCount ¶
func (a *ASTAssertions) AssertCatchClausesCount(tryStmt *ast.TryStatement, expectedCount int)
AssertCatchClausesCount 断言catch子句数量
func (*ASTAssertions) AssertClass ¶
func (a *ASTAssertions) AssertClass(node ast.Node, expectedName string) *ast.ClassExpression
AssertClass 断言类表达式
func (*ASTAssertions) AssertEchoStatement ¶
func (a *ASTAssertions) AssertEchoStatement(stmt ast.Statement, expectedArgCount int) *ast.EchoStatement
AssertEchoStatement 断言echo语句
func (*ASTAssertions) AssertExpressionStatement ¶
func (a *ASTAssertions) AssertExpressionStatement(stmt ast.Statement) *ast.ExpressionStatement
AssertExpressionStatement 断言表达式语句
func (*ASTAssertions) AssertFullyQualifiedCall ¶
func (a *ASTAssertions) AssertFullyQualifiedCall(callExpr *ast.CallExpression, expectedName string)
AssertFullyQualifiedCall 断言完全限定的函数调用
func (*ASTAssertions) AssertFunctionBody ¶
func (a *ASTAssertions) AssertFunctionBody(funcDecl *ast.FunctionDeclaration, expectedStatements int)
AssertFunctionBody 断言函数体
func (*ASTAssertions) AssertFunctionDeclaration ¶
func (a *ASTAssertions) AssertFunctionDeclaration(stmt ast.Statement, expectedName string) *ast.FunctionDeclaration
AssertFunctionDeclaration 断言函数声明
func (*ASTAssertions) AssertGlobalNamespaceStatement ¶
func (a *ASTAssertions) AssertGlobalNamespaceStatement(stmt ast.Statement) *ast.NamespaceStatement
AssertGlobalNamespaceStatement 断言全局namespace语句
func (*ASTAssertions) AssertIdentifier ¶
func (a *ASTAssertions) AssertIdentifier(node ast.Node, expectedName string) *ast.IdentifierNode
AssertIdentifier 断言标识符节点
func (*ASTAssertions) AssertMatchExpression ¶
func (a *ASTAssertions) AssertMatchExpression(expr ast.Expression) *ast.MatchExpression
AssertMatchExpression 断言Match表达式
func (*ASTAssertions) AssertMethodCall ¶
func (a *ASTAssertions) AssertMethodCall(node ast.Node, expectedObject, expectedMethod string) *ast.MethodCallExpression
AssertMethodCall 断言方法调用
func (*ASTAssertions) AssertNamespaceStatement ¶
func (a *ASTAssertions) AssertNamespaceStatement(stmt ast.Statement, expectedName string) *ast.NamespaceStatement
AssertNamespaceStatement 断言namespace语句
func (*ASTAssertions) AssertNumberLiteral ¶
func (a *ASTAssertions) AssertNumberLiteral(node ast.Node, expectedValue string) *ast.NumberLiteral
AssertNumberLiteral 断言数字字面量
func (*ASTAssertions) AssertProgramBody ¶
AssertProgramBody 断言程序体
func (*ASTAssertions) AssertReturnStatement ¶
func (a *ASTAssertions) AssertReturnStatement(stmt ast.Statement) *ast.ReturnStatement
AssertReturnStatement 断言return语句
func (*ASTAssertions) AssertStringLiteral ¶
func (a *ASTAssertions) AssertStringLiteral(node ast.Node, expectedValue, expectedRaw string) *ast.StringLiteral
AssertStringLiteral 断言字符串字面量
func (*ASTAssertions) AssertTernaryExpression ¶
func (a *ASTAssertions) AssertTernaryExpression(node ast.Node) *ast.TernaryExpression
AssertTernaryExpression 断言三元表达式
func (*ASTAssertions) AssertTraitDeclaration ¶
func (a *ASTAssertions) AssertTraitDeclaration(stmt ast.Statement, expectedName string) *ast.TraitDeclaration
AssertTraitDeclaration 断言Trait声明
func (*ASTAssertions) AssertTryBlockEmpty ¶
func (a *ASTAssertions) AssertTryBlockEmpty(tryStmt *ast.TryStatement)
AssertTryBlockEmpty 断言try块为空
func (*ASTAssertions) AssertTryBlockStatements ¶
func (a *ASTAssertions) AssertTryBlockStatements(tryStmt *ast.TryStatement, expectedCount int)
AssertTryBlockStatements 断言try块中的语句数量
func (*ASTAssertions) AssertTryStatement ¶
func (a *ASTAssertions) AssertTryStatement(stmt ast.Statement) *ast.TryStatement
AssertTryStatement 断言try语句
func (*ASTAssertions) AssertVariable ¶
AssertVariable 断言变量节点
type ArrayElement ¶
ArrayElement 表示数组元素
type BenchmarkBuilder ¶
type BenchmarkBuilder struct {
// contains filtered or unexported fields
}
BenchmarkBuilder 性能测试构建器
func NewBenchmarkBuilder ¶
func NewBenchmarkBuilder(name string, parserFactory ParserFactory) *BenchmarkBuilder
NewBenchmarkBuilder 创建性能测试构建器
func (*BenchmarkBuilder) Add ¶
func (b *BenchmarkBuilder) Add(name, source string) *BenchmarkBuilder
Add 添加性能测试
type CatchClause ¶
type CatchClause struct {
ExceptionType string
VariableName string
BodyValidator ValidationFunc
}
类型定义
func ValidateCatchClause ¶
func ValidateCatchClause(exceptionType, varName string, bodyValidator ValidationFunc) CatchClause
ValidateCatchClause 创建catch子句验证器
type ErrorTestBuilder ¶
type ErrorTestBuilder struct {
// contains filtered or unexported fields
}
ErrorTestBuilder 错误测试构建器
func NewErrorTestBuilder ¶
func NewErrorTestBuilder(parserFactory ParserFactory) *ErrorTestBuilder
NewErrorTestBuilder 创建错误测试构建器
func (*ErrorTestBuilder) ExpectError ¶
func (b *ErrorTestBuilder) ExpectError(t *testing.T, source string, expectedErrorSubstring string)
ExpectError 验证解析错误
func (*ErrorTestBuilder) ExpectNoError ¶
func (b *ErrorTestBuilder) ExpectNoError(t *testing.T, source string)
ExpectNoError 验证无解析错误
func (*ErrorTestBuilder) ExpectRecovery ¶
func (b *ErrorTestBuilder) ExpectRecovery(t *testing.T, source string, expectedStatementCount int)
ExpectRecovery 验证错误恢复(有错误但仍能解析部分内容)
type ErrorTestCase ¶
type ErrorTestCase struct {
Name string
Source string
ExpectError bool
ErrorKeyword string
RecoverCount int // 错误恢复时期望的语句数量
}
ErrorTestCase 错误测试用例
type ErrorTestSuite ¶
type ErrorTestSuite struct {
// contains filtered or unexported fields
}
ErrorTestSuite 错误测试套件
func NewErrorTestSuite ¶
func NewErrorTestSuite(name string, parserFactory ParserFactory) *ErrorTestSuite
NewErrorTestSuite 创建错误测试套件
func (*ErrorTestSuite) Add ¶
func (s *ErrorTestSuite) Add(testCase ErrorTestCase) *ErrorTestSuite
Add 添加错误测试用例
func (*ErrorTestSuite) AddError ¶
func (s *ErrorTestSuite) AddError(name, source, errorKeyword string) *ErrorTestSuite
AddError 添加期望错误的测试
func (*ErrorTestSuite) AddRecovery ¶
func (s *ErrorTestSuite) AddRecovery(name, source string, recoverCount int) *ErrorTestSuite
AddRecovery 添加错误恢复测试
func (*ErrorTestSuite) AddSuccess ¶
func (s *ErrorTestSuite) AddSuccess(name, source string) *ErrorTestSuite
AddSuccess 添加期望成功的测试
type GlobalConfig ¶
type GlobalConfig struct {
DefaultStrictMode bool
EnableDebug bool
TestDataDir string
GoldenFileDir string
BenchmarkEnabled bool
CoverageEnabled bool
}
GlobalConfig 全局测试配置
type InterpolationPart ¶
type InterpolationPart struct {
Text string // 字符串文本
Variable string // 变量名
HasBraces bool // 是否有花括号
}
InterpolationPart 表示插值部分
type PHPSourceBuilder ¶
type PHPSourceBuilder struct {
// contains filtered or unexported fields
}
PHPSourceBuilder PHP源码构建器
func (*PHPSourceBuilder) Add ¶
func (b *PHPSourceBuilder) Add(code string) *PHPSourceBuilder
Add 添加PHP代码
func (*PHPSourceBuilder) AddClass ¶
func (b *PHPSourceBuilder) AddClass(name, body string) *PHPSourceBuilder
AddClass 添加类定义
func (*PHPSourceBuilder) AddEcho ¶
func (b *PHPSourceBuilder) AddEcho(args ...string) *PHPSourceBuilder
AddEcho 添加echo语句
func (*PHPSourceBuilder) AddFor ¶
func (b *PHPSourceBuilder) AddFor(init, condition, increment, body string) *PHPSourceBuilder
AddFor 添加for语句
func (*PHPSourceBuilder) AddFunction ¶
func (b *PHPSourceBuilder) AddFunction(name string, params []string, body string) *PHPSourceBuilder
AddFunction 添加函数定义
func (*PHPSourceBuilder) AddIf ¶
func (b *PHPSourceBuilder) AddIf(condition, body string) *PHPSourceBuilder
AddIf 添加if语句
func (*PHPSourceBuilder) AddLine ¶
func (b *PHPSourceBuilder) AddLine(code string) *PHPSourceBuilder
AddLine 添加一行PHP代码
func (*PHPSourceBuilder) AddTryCatch ¶
func (b *PHPSourceBuilder) AddTryCatch(tryBody, catchVar, catchBody string) *PHPSourceBuilder
AddTryCatch 添加try-catch语句
func (*PHPSourceBuilder) AddVariable ¶
func (b *PHPSourceBuilder) AddVariable(name, value string) *PHPSourceBuilder
AddVariable 添加变量赋值
func (*PHPSourceBuilder) AddWhile ¶
func (b *PHPSourceBuilder) AddWhile(condition, body string) *PHPSourceBuilder
AddWhile 添加while语句
type ParserFactory ¶
type ParserFactory func(*lexer.Lexer) ParserInterface
ParserFactory 解析器工厂函数类型
var DefaultParserFactory ParserFactory
DefaultParserFactory 默认解析器工厂函数类型 该函数需要在parser包中实现,避免循环依赖
type ParserInterface ¶
ParserInterface 定义解析器接口以避免循环依赖
type ParserTestBuilder ¶
type ParserTestBuilder struct {
// contains filtered or unexported fields
}
ParserTestBuilder 解析器测试构建器
func NewParserTestBuilder ¶
func NewParserTestBuilder(parserFactory ParserFactory) *ParserTestBuilder
NewParserTestBuilder 创建解析器测试构建器 parserFactory 参数用于创建解析器实例
func NewQuickTestBuilder ¶
func NewQuickTestBuilder(factory ParserFactory) *ParserTestBuilder
NewQuickTestBuilder 创建快速测试构建器(用于parser包内部)
func NewTestBuilder ¶
func NewTestBuilder() *ParserTestBuilder
NewTestBuilder 创建带默认解析器工厂的测试构建器 使用前需要在parser包中设置DefaultParserFactory
func (*ParserTestBuilder) Test ¶
func (b *ParserTestBuilder) Test(t *testing.T, source string, validator func(*TestContext))
Test 执行测试
func (*ParserTestBuilder) TestTableDriven ¶
func (b *ParserTestBuilder) TestTableDriven(t *testing.T, tests []struct { Name string Source string Validator func(*TestContext) })
TestTableDriven 执行表驱动测试
func (*ParserTestBuilder) WithConfig ¶
func (b *ParserTestBuilder) WithConfig(config *TestConfig) *ParserTestBuilder
WithConfig 设置测试配置
func (*ParserTestBuilder) WithSetup ¶
func (b *ParserTestBuilder) WithSetup(setup func(*TestContext)) *ParserTestBuilder
WithSetup 添加设置函数
func (*ParserTestBuilder) WithStrictMode ¶
func (b *ParserTestBuilder) WithStrictMode(strict bool) *ParserTestBuilder
WithStrictMode 设置严格模式
type ParserTester ¶
type ParserTester struct {
// contains filtered or unexported fields
}
ParserTester 解析器测试器,用于快速测试
func NewParserTester ¶
func NewParserTester(t *testing.T, parserFactory ParserFactory) *ParserTester
NewParserTester 创建解析器测试器
func (*ParserTester) Quick ¶
func (pt *ParserTester) Quick(source string, validator ValidationFunc)
Quick 快速测试
func (*ParserTester) QuickError ¶
func (pt *ParserTester) QuickError(source, errorKeyword string)
QuickError 快速测试错误
func (*ParserTester) QuickString ¶
func (pt *ParserTester) QuickString(varName, value, raw string)
QuickString 快速测试字符串赋值
func (*ParserTester) QuickSuccess ¶
func (pt *ParserTester) QuickSuccess(source string)
QuickSuccess 快速测试成功解析
func (*ParserTester) QuickVariable ¶
func (pt *ParserTester) QuickVariable(varName, value string)
QuickVariable 快速测试变量赋值
type StringInterpolation ¶
type StringInterpolation struct {
Parts []InterpolationPart
}
StringInterpolation 表示字符串插值
type SwitchCase ¶
type SwitchCase struct {
Value string
Validators []ValidationFunc
IsDefault bool
}
func ValidateDefaultCase ¶
func ValidateDefaultCase(validators ...ValidationFunc) SwitchCase
ValidateDefaultCase 创建default case验证器
func ValidateSwitchCase ¶
func ValidateSwitchCase(value string, validators ...ValidationFunc) SwitchCase
ValidateSwitchCase 创建switch case验证器
type TestCase ¶
type TestCase struct {
Name string
Source string
Validator ValidationFunc
Skip bool
Only bool
Tags []string
}
TestCase 标准测试用例结构
type TestConfig ¶
TestConfig 测试配置选项
type TestContext ¶
type TestContext struct {
T *testing.T
Parser ParserInterface
Lexer *lexer.Lexer
Program *ast.Program
Config *TestConfig
}
TestContext 提供测试上下文和工具
type TestDataItem ¶
type TestDataItem struct {
Name string
Source string
ExpectedAST interface{} // 可以是任何期望的AST结构表示
Tags []string
Skip bool
}
TestDataItem 测试数据项
type TestSuiteBuilder ¶
type TestSuiteBuilder struct {
// contains filtered or unexported fields
}
TestSuiteBuilder 测试套件构建器
func NewTestSuiteBuilder ¶
func NewTestSuiteBuilder(name string, parserFactory ParserFactory) *TestSuiteBuilder
NewTestSuiteBuilder 创建测试套件构建器
func (*TestSuiteBuilder) Add ¶
func (b *TestSuiteBuilder) Add(testCase TestCase) *TestSuiteBuilder
Add 添加测试用例
func (*TestSuiteBuilder) AddClass ¶
func (b *TestSuiteBuilder) AddClass(name, className, classBody string, validators ...func(*ast.ClassExpression, *testing.T)) *TestSuiteBuilder
AddClass 添加类测试
func (*TestSuiteBuilder) AddControlFlow ¶
func (b *TestSuiteBuilder) AddControlFlow(name, flowType, source string, validators ...func(ast.Statement, *testing.T)) *TestSuiteBuilder
AddControlFlow 添加控制流测试
func (*TestSuiteBuilder) AddEcho ¶
func (b *TestSuiteBuilder) AddEcho(name string, args []string, validators ...func(ast.Node, *testing.T)) *TestSuiteBuilder
AddEcho 添加echo测试
func (*TestSuiteBuilder) AddFunction ¶
func (b *TestSuiteBuilder) AddFunction(name, funcName string, params []string, validators ...func(*ast.FunctionDeclaration, *testing.T)) *TestSuiteBuilder
AddFunction 添加函数测试
func (*TestSuiteBuilder) AddSimple ¶
func (b *TestSuiteBuilder) AddSimple(name, source string, validator ValidationFunc) *TestSuiteBuilder
AddSimple 添加简单测试用例
func (*TestSuiteBuilder) AddStringAssignment ¶
func (b *TestSuiteBuilder) AddStringAssignment(name, varName, value, raw string) *TestSuiteBuilder
AddStringAssignment 添加字符串赋值测试
func (*TestSuiteBuilder) AddVariableAssignment ¶
func (b *TestSuiteBuilder) AddVariableAssignment(name, varName, valueSource string) *TestSuiteBuilder
AddVariableAssignment 添加变量赋值测试
func (*TestSuiteBuilder) Only ¶
func (b *TestSuiteBuilder) Only(testName string) *TestSuiteBuilder
Only 仅运行特定测试
func (*TestSuiteBuilder) Skip ¶
func (b *TestSuiteBuilder) Skip(testName string) *TestSuiteBuilder
Skip 标记跳过测试
func (*TestSuiteBuilder) WithConfig ¶
func (b *TestSuiteBuilder) WithConfig(config *TestConfig) *TestSuiteBuilder
WithConfig 设置配置
type ValidationFunc ¶
type ValidationFunc func(*TestContext)
ValidationFunc 验证函数类型
func ValidateAbstractClass ¶
func ValidateAbstractClass(className string) ValidationFunc
ValidateAbstractClass 验证abstract类
func ValidateAbstractClassInExpressionStatement ¶
func ValidateAbstractClassInExpressionStatement(className string) ValidationFunc
ValidateAbstractClassInExpressionStatement 验证abstract类在表达式语句中
func ValidateAdditionAssignment ¶
func ValidateAdditionAssignment(varName string) ValidationFunc
ValidateAdditionAssignment 验证加法赋值 (+=)
func ValidateAnonymousFunctionAssignment ¶
func ValidateAnonymousFunctionAssignment(varName string, bodyValidator ValidationFunc) ValidationFunc
ValidateAnonymousFunctionAssignment 验证匿名函数赋值
func ValidateAnonymousFunctionWithParams ¶
func ValidateAnonymousFunctionWithParams(varName string, params []string, bodyValidator ValidationFunc) ValidationFunc
ValidateAnonymousFunctionWithParams 验证带参数的匿名函数
func ValidateArrayAccess ¶
func ValidateArrayAccess(varName, arrayVar, index string) ValidationFunc
ValidateArrayAccess 验证数组访问
func ValidateArrayAssignment ¶
func ValidateArrayAssignment(varName string, elements []ArrayElement) ValidationFunc
ValidateArrayAssignment 验证数组赋值
func ValidateArrowFunctionAssignment ¶
func ValidateArrowFunctionAssignment(varName string, params []string, bodyValidator ValidationFunc) ValidationFunc
ValidateArrowFunctionAssignment 验证箭头函数赋值
func ValidateAssignment ¶
func ValidateAssignment(varName, operator string) ValidationFunc
ValidateAssignment 验证赋值表达式,支持指定操作符
func ValidateAssignmentExpression ¶
func ValidateAssignmentExpression(varName, value string) ValidationFunc
ValidateAssignmentExpression 创建赋值验证器
func ValidateAssignmentOperation ¶
func ValidateAssignmentOperation(varName, operator, valueVar string) ValidationFunc
ValidateAssignmentOperation 验证赋值操作
func ValidateBackedEnum ¶
func ValidateBackedEnum(enumName, backingType string, cases []EnumCase) ValidationFunc
ValidateBackedEnum 验证带值的枚举 (简化版本)
func ValidateBasicAssignment ¶
func ValidateBasicAssignment(varName string) ValidationFunc
ValidateBasicAssignment 验证基础赋值 (=)
func ValidateBinaryAssignment ¶
func ValidateBinaryAssignment(varName, leftVar, operator, rightVar string) ValidationFunc
ValidateBinaryAssignment 验证二元表达式赋值
func ValidateBinaryExpression ¶
func ValidateBinaryExpression(leftVar, operator, rightValue string) ValidationFunc
ValidateBinaryExpression 创建二元表达式验证器
func ValidateBinaryOperation ¶
func ValidateBinaryOperation(operator string, leftValidator, rightValidator func(ast.Node, *testing.T)) ValidationFunc
ValidateBinaryOperation 验证二元运算表达式
func ValidateBitwiseAndAssignment ¶
func ValidateBitwiseAndAssignment(varName string) ValidationFunc
ValidateBitwiseAndAssignment 验证按位与赋值 (&=)
func ValidateBitwiseOrAssignment ¶
func ValidateBitwiseOrAssignment(varName string) ValidationFunc
ValidateBitwiseOrAssignment 验证按位或赋值 (|=)
func ValidateBitwiseXorAssignment ¶
func ValidateBitwiseXorAssignment(varName string) ValidationFunc
ValidateBitwiseXorAssignment 验证按位异或赋值 (^=)
func ValidateBreakStatement ¶
func ValidateBreakStatement() ValidationFunc
ValidateBreakStatement 创建break语句验证器
func ValidateChainedArrayAccess ¶
func ValidateChainedArrayAccess(varName, arrayVar string, indices []string) ValidationFunc
ValidateChainedArrayAccess 验证链式数组访问
func ValidateChainedStaticCall ¶
func ValidateChainedStaticCall(varName, className, firstMethod string, firstArgs []string, secondMethod string) ValidationFunc
ValidateChainedStaticCall 验证链式静态调用 (简化版本)
func ValidateClass ¶
func ValidateClass(expectedName string, validators ...func(*ast.ClassExpression, *testing.T)) ValidationFunc
ValidateClass 验证类声明
func ValidateClassDeclaration ¶
func ValidateClassDeclaration(className, parentClass string, interfaces []string, memberValidator ValidationFunc) ValidationFunc
ValidateClassDeclaration 验证类声明
func ValidateClassInExpressionStatement ¶
func ValidateClassInExpressionStatement(className string) ValidationFunc
ValidateClassInExpressionStatement 验证表达式语句中的类声明
func ValidateClassWithInheritance ¶
func ValidateClassWithInheritance(className, parentClass string, memberValidator ValidationFunc) ValidationFunc
ValidateClassWithInheritance 验证带继承的类
func ValidateClassWithInterfaces ¶
func ValidateClassWithInterfaces(className string, interfaces []string) ValidationFunc
ValidateClassWithInterfaces 验证实现接口的类
func ValidateClosureWithUse ¶
func ValidateClosureWithUse(varName string, params []string, useVars []string, bodyValidator ValidationFunc) ValidationFunc
ValidateClosureWithUse 验证带use的闭包
func ValidateCoalesceAssignment ¶
func ValidateCoalesceAssignment(varName string) ValidationFunc
ValidateCoalesceAssignment 验证null合并赋值 (??=)
func ValidateCoalesceExpression ¶
func ValidateCoalesceExpression(varName, leftVar, rightVar string) ValidationFunc
ValidateCoalesceExpression 验证null合并表达式
func ValidateConcatenationAssignment ¶
func ValidateConcatenationAssignment(varName string) ValidationFunc
ValidateConcatenationAssignment 验证字符串连接赋值 (.=)
func ValidateControlFlow ¶
func ValidateControlFlow(expectedType string, validators ...func(ast.Statement, *testing.T)) ValidationFunc
ValidateControlFlow 验证控制流语句
func ValidateDivisionAssignment ¶
func ValidateDivisionAssignment(varName string) ValidationFunc
ValidateDivisionAssignment 验证除法赋值 (/=)
func ValidateEcho ¶
ValidateEcho 验证echo语句
func ValidateEchoArgs ¶
func ValidateEchoArgs(args []string) ValidationFunc
ValidateEchoArgs 创建echo语句验证器
func ValidateEchoVariable ¶
func ValidateEchoVariable(varName string) ValidationFunc
ValidateEchoVariable 创建echo变量验证器
func ValidateEnumDeclaration ¶
func ValidateEnumDeclaration(enumName, backingType string, cases []string) ValidationFunc
ValidateEnumDeclaration 验证枚举声明 (简化版本)
func ValidateErrorMessage ¶
func ValidateErrorMessage(expectedKeywords ...string) ValidationFunc
ValidateErrorMessage 创建错误消息验证函数
func ValidateFinalClass ¶
func ValidateFinalClass(className string) ValidationFunc
ValidateFinalClass 验证final类
func ValidateFinalClassInExpressionStatement ¶
func ValidateFinalClassInExpressionStatement(className string) ValidationFunc
ValidateFinalClassInExpressionStatement 验证final类在表达式语句中
func ValidateForStatement ¶
func ValidateForStatement(initValidator, testValidator, updateValidator, bodyValidator ValidationFunc) ValidationFunc
ValidateForStatement 验证for语句
func ValidateForeachStatement ¶
func ValidateForeachStatement(iterableVar, keyVar, valueVar string, bodyValidators ...ValidationFunc) ValidationFunc
ValidateForeachStatement 验证foreach语句
func ValidateFunction ¶
func ValidateFunction(expectedName string, expectedParamCount int, validators ...func(*ast.FunctionDeclaration, *testing.T)) ValidationFunc
ValidateFunction 验证函数声明
func ValidateFunctionCall ¶
func ValidateFunctionCall(funcName string, args ...string) ValidationFunc
ValidateFunctionCall 创建函数调用验证器
func ValidateFunctionDeclaration ¶
func ValidateFunctionDeclaration(funcName string, params []string, returnType string, bodyValidator ValidationFunc) ValidationFunc
ValidateFunctionDeclaration 验证函数声明
func ValidateFunctionWithIntersectionType ¶
func ValidateFunctionWithIntersectionType(funcName, intersectionType, paramName string, bodyValidator ValidationFunc) ValidationFunc
ValidateFunctionWithIntersectionType 验证交集类型函数 (简化版本)
func ValidateFunctionWithNullableUnionType ¶
func ValidateFunctionWithNullableUnionType(funcName, nullableUnionType string, bodyValidator ValidationFunc) ValidationFunc
ValidateFunctionWithNullableUnionType 验证可空联合类型函数 (简化版本)
func ValidateFunctionWithParameters ¶
func ValidateFunctionWithParameters(funcName string, params []string, bodyValidator ValidationFunc) ValidationFunc
ValidateFunctionWithParameters 验证带参数的函数
func ValidateFunctionWithReturnType ¶
func ValidateFunctionWithReturnType(funcName string, returnType string, bodyValidator ValidationFunc) ValidationFunc
ValidateFunctionWithReturnType 验证带返回类型的函数
func ValidateFunctionWithUnionType ¶
func ValidateFunctionWithUnionType(funcName, unionType, paramName string, bodyValidator ValidationFunc) ValidationFunc
ValidateFunctionWithUnionType 验证联合类型函数 (简化版本)
func ValidateHeredocAssignment ¶
func ValidateHeredocAssignment(varName, expectedValue string) ValidationFunc
ValidateHeredocAssignment 验证Heredoc赋值
func ValidateIfElseStatement ¶
func ValidateIfElseStatement(testValidator ValidationFunc, consequentValidator ValidationFunc, alternateValidator ValidationFunc) ValidationFunc
ValidateIfElseStatement 验证if-else语句
func ValidateIfStatement ¶
func ValidateIfStatement(testValidator ValidationFunc, consequentValidators ...ValidationFunc) ValidationFunc
ValidateIfStatement 验证if语句
func ValidateInstanceofExpression ¶
func ValidateInstanceofExpression(varName, objectVar, className string) ValidationFunc
ValidateInstanceofExpression 验证instanceof表达式
func ValidateInterpolatedStringAssignment ¶
func ValidateInterpolatedStringAssignment(varName string, interpolation StringInterpolation) ValidationFunc
ValidateInterpolatedStringAssignment 验证插值字符串赋值
func ValidateLeftShiftAssignment ¶
func ValidateLeftShiftAssignment(varName string) ValidationFunc
ValidateLeftShiftAssignment 验证左移赋值 (<<=)
func ValidateMatchExpression ¶
func ValidateMatchExpression(varName, matchVar string, arms []MatchArm) ValidationFunc
ValidateMatchExpression 验证match表达式 (简化版本)
func ValidateMatchWithMultipleConditions ¶
func ValidateMatchWithMultipleConditions(varName, matchVar string, arms []MatchArm) ValidationFunc
ValidateMatchWithMultipleConditions 验证多条件match表达式 (简化版本)
func ValidateModuloAssignment ¶
func ValidateModuloAssignment(varName string) ValidationFunc
ValidateModuloAssignment 验证模运算赋值 (%=)
func ValidateMultiplicationAssignment ¶
func ValidateMultiplicationAssignment(varName string) ValidationFunc
ValidateMultiplicationAssignment 验证乘法赋值 (*=)
func ValidateNowdocAssignment ¶
func ValidateNowdocAssignment(varName, expectedValue string) ValidationFunc
ValidateNowdocAssignment 验证Nowdoc赋值
func ValidatePostfixAssignment ¶
func ValidatePostfixAssignment(varName, operandVar, operator string) ValidationFunc
ValidatePostfixAssignment 验证后缀表达式赋值
func ValidatePostfixExpression ¶
func ValidatePostfixExpression(varName, operator string) ValidationFunc
ValidatePostfixExpression 创建后缀表达式验证器
func ValidatePowerAssignment ¶
func ValidatePowerAssignment(varName string) ValidationFunc
ValidatePowerAssignment 验证幂运算赋值 (**=)
func ValidatePrefixExpression ¶
func ValidatePrefixExpression(varName, operandVar, operator string) ValidationFunc
ValidatePrefixExpression 验证前缀表达式
func ValidatePropertyDeclaration ¶
func ValidatePropertyDeclaration(visibility, varName, typeName, defaultValue string) ValidationFunc
ValidatePropertyDeclaration 验证属性声明
func ValidateReturnBinaryExpression ¶
func ValidateReturnBinaryExpression(leftVar, operator, rightVar string) ValidationFunc
ValidateReturnBinaryExpression 验证return二元表达式
func ValidateReturnStatement ¶
func ValidateReturnStatement(expectedValue string) ValidationFunc
ValidateReturnStatement 验证return语句
func ValidateReturnVariable ¶
func ValidateReturnVariable(varName string) ValidationFunc
ValidateReturnVariable 验证return变量
func ValidateRightShiftAssignment ¶
func ValidateRightShiftAssignment(varName string) ValidationFunc
ValidateRightShiftAssignment 验证右移赋值 (>>=)
func ValidateStaticConstantAccess ¶
func ValidateStaticConstantAccess(varName, className, constantName string) ValidationFunc
ValidateStaticConstantAccess 验证静态常量访问
func ValidateStaticMethodCall ¶
func ValidateStaticMethodCall(varName, className, methodName string, args []string) ValidationFunc
ValidateStaticMethodCall 验证静态方法调用
func ValidateStaticPropertyAccess ¶
func ValidateStaticPropertyAccess(varName, className, propertyName string) ValidationFunc
ValidateStaticPropertyAccess 验证静态属性访问
func ValidateStringAssignment ¶
func ValidateStringAssignment(varName, expectedValue, expectedRaw string) ValidationFunc
ValidateStringAssignment 创建字符串赋值验证函数
func ValidateSubtractionAssignment ¶
func ValidateSubtractionAssignment(varName string) ValidationFunc
ValidateSubtractionAssignment 验证减法赋值 (-=)
func ValidateSwitchStatement ¶
func ValidateSwitchStatement(discriminantVar string, cases []SwitchCase) ValidationFunc
ValidateSwitchStatement 验证switch语句
func ValidateTernaryExpression ¶
func ValidateTernaryExpression(varName, conditionVar, trueVar, falseVar string) ValidationFunc
ValidateTernaryExpression 验证三元表达式
func ValidateTryCatchFinallyStatement ¶
func ValidateTryCatchFinallyStatement(tryValidator ValidationFunc, catchValidator CatchClause, finallyValidator ValidationFunc) ValidationFunc
ValidateTryCatchFinallyStatement 验证try-catch-finally语句
func ValidateTryCatchStatement ¶
func ValidateTryCatchStatement(tryValidator ValidationFunc, catchValidator CatchClause) ValidationFunc
ValidateTryCatchStatement 验证try-catch语句
func ValidateTryMultipleCatchStatement ¶
func ValidateTryMultipleCatchStatement(tryValidator ValidationFunc, catchValidators []CatchClause) ValidationFunc
ValidateTryMultipleCatchStatement 验证多个catch子句的try语句
func ValidateTypedArrowFunction ¶
func ValidateTypedArrowFunction(varName string, params []TypedParam, returnType string, bodyValidator ValidationFunc) ValidationFunc
ValidateTypedArrowFunction 验证带类型的箭头函数
func ValidateTypedFunction ¶
func ValidateTypedFunction(funcName string, params []TypedParam, bodyValidator ValidationFunc) ValidationFunc
ValidateTypedFunction 验证带类型参数的函数
func ValidateVariableAssignment ¶
func ValidateVariableAssignment(varName string) ValidationFunc
ValidateVariableAssignment 验证变量赋值的别名,避免与已有函数冲突
func ValidateVariableExpression ¶
func ValidateVariableExpression(varName string) ValidationFunc
ValidateVariable 创建变量验证器
func ValidateWhileStatement ¶
func ValidateWhileStatement(testValidator ValidationFunc, bodyValidators ...ValidationFunc) ValidationFunc
ValidateWhileStatement 验证while语句