Add Clusure ReturnType test
This commit is contained in:
		
							parent
							
								
									3ae13a3f04
								
							
						
					
					
						commit
						4c64183e0c
					
				| @ -4,6 +4,8 @@ import ( | ||||
| 	"bytes" | ||||
| 	"testing" | ||||
| 
 | ||||
| 	"github.com/z7zmey/php-parser/node/name" | ||||
| 
 | ||||
| 	"github.com/z7zmey/php-parser/node/expr" | ||||
| 
 | ||||
| 	"github.com/z7zmey/php-parser/node" | ||||
| @ -80,3 +82,27 @@ func TestClosureUse(t *testing.T) { | ||||
| 	actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") | ||||
| 	assertEqual(t, expected, actual) | ||||
| } | ||||
| 
 | ||||
| func TestClosureReturnType(t *testing.T) { | ||||
| 	src := `<? function(): void {};` | ||||
| 
 | ||||
| 	expected := &stmt.StmtList{ | ||||
| 		Stmts: []node.Node{ | ||||
| 			&stmt.Expression{ | ||||
| 				Expr: &expr.Closure{ | ||||
| 					ReturnsRef:    false, | ||||
| 					Static:        false, | ||||
| 					PhpDocComment: "", | ||||
| 					Uses:          []node.Node{}, | ||||
| 					ReturnType: &name.Name{ | ||||
| 						Parts: []node.Node{&name.NamePart{Value: "void"}}, | ||||
| 					}, | ||||
| 					Stmts: []node.Node{}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") | ||||
| 	assertEqual(t, expected, actual) | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user