package php8_test import ( "testing" "git.maride.cc/maride/php-parser/internal/php8" "git.maride.cc/maride/php-parser/internal/tester" "git.maride.cc/maride/php-parser/pkg/conf" "git.maride.cc/maride/php-parser/pkg/position" "git.maride.cc/maride/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 = "