package php8_test import ( "testing" "github.com/VKCOM/php-parser/internal/php8" "github.com/VKCOM/php-parser/internal/tester" "github.com/VKCOM/php-parser/pkg/conf" "github.com/VKCOM/php-parser/pkg/token" "gotest.tools/assert" ) func TestNullsafeMethodCallTokens(t *testing.T) { suite := tester.NewLexerTokenStringTestSuite(t) suite.UsePHP8() suite.Code = "foo();" suite.Expected = []string{ "$a", "?->", "foo", "(", ")", ";", } suite.Run() } func TestNullsafePropertyFetchTokens(t *testing.T) { suite := tester.NewLexerTokenStringTestSuite(t) suite.UsePHP8() suite.Code = "prop;" suite.Expected = []string{ "$a", "?->", "prop", ";", } suite.Run() } func TestNullsafePropertyFetchInStringTokens(t *testing.T) { suite := tester.NewLexerTokenStringTestSuite(t) suite.UsePHP8() suite.Code = "prop\";" suite.Expected = []string{ "\"", "$a", "?->", "prop", "\"", ";", } suite.Run() } func TestNullsafeMethodCallTokensFreeFloating(t *testing.T) { suite := tester.NewLexerTokenFreeFloatingTestSuite(t) suite.UsePHP8() suite.Code = ` bar ( '' ) ;` suite.Expected = [][]*token.Token{ { { ID: token.T_OPEN_TAG, Value: []byte(" 100 }" suite.Expected = []string{ "match", "(", "$a", ")", "{", "10", "=>", "100", "}", } suite.Run() } func TestMatchWithDefaultStringTokens(t *testing.T) { suite := tester.NewLexerTokenStringTestSuite(t) suite.UsePHP8() suite.Code = " 10 }" suite.Expected = []string{ "match", "(", "$a", ")", "{", "default", "=>", "10", "}", } suite.Run() } func TestAttributeTokens(t *testing.T) { suite := tester.NewLexerTokenStringTestSuite(t) suite.UsePHP8() suite.Code = "