77 "testing"
88
99 "github.com/hulo-lang/hulo/syntax/batch/token"
10+ "github.com/stretchr/testify/assert"
1011)
1112
1213type FileBuilder struct {
@@ -184,7 +185,7 @@ func ExitStmt(args ...Expr) *ExprStmt {
184185}
185186
186187// GotoStmt 创建 GOTO 语句
187- func GotoStmt (label string ) * GotoStmt {
188+ func Goto (label string ) * GotoStmt {
188189 return & GotoStmt {Label : label }
189190}
190191
@@ -302,10 +303,10 @@ func TestIfStatement(t *testing.T) {
302303 EchoOff ().
303304 If (Eq (Str ("VAR" ), Literal ("value" ))).
304305 Then (
305- EchoStmt ( Literal ("Match" )),
306+ & ExprStmt { X : Cmd ( "ECHO" , Literal ("Match" ))} ,
306307 ).
307308 Else (
308- EchoStmt ( Literal ("No Match" )),
309+ & ExprStmt { X : Cmd ( "ECHO" , Literal ("No Match" ))} ,
309310 ).
310311 EndIf ().
311312 Exit (Literal ("0" )).
@@ -408,15 +409,13 @@ func TestNestedIfExample(t *testing.T) {
408409 Exit (Literal ("0" )).
409410 Build ()
410411
411- if err != nil {
412- t .Fatal (err )
413- }
412+ assert .NoError (t , err )
414413
415414 Print (file )
416415}
417416
418- // TestAST 测试辅助函数
419- func TestAST (t * testing.T , name string , builder func () (* File , error )) {
417+ // testAST 测试辅助函数
418+ func testAST (t * testing.T , name string , builder func () (* File , error )) {
420419 t .Run (name , func (t * testing.T ) {
421420 file , err := builder ()
422421 if err != nil {
@@ -429,7 +428,7 @@ func TestAST(t *testing.T, name string, builder func() (*File, error)) {
429428}
430429
431430func TestWithHelper (t * testing.T ) {
432- TestAST (t , "Basic IF" , func () (* File , error ) {
431+ testAST (t , "Basic IF" , func () (* File , error ) {
433432 return NewFile ().
434433 EchoOff ().
435434 If (Eq (Str ("VAR" ), Literal ("value" ))).
0 commit comments