import HelderCore import Testing @Suite struct PHPGrammarTests { private let source = """ name} $prefix") . self::STATUS_ACTIVE . 0x1F; } } """ @Test("the open tag and keywords read as keywords") func keywords() { #expect(role(" is a function name, a property is a variable") func arrowAccess() { let text = "save(); $a->name;" #expect(role("save", in: text, .php) == .plain) #expect(role("name", in: text, .php) == .variable) #expect(role("->", in: text, .php) == .keyword) } @Test("strings interpolate variables, single quotes do not") func interpolation() { let text = "name}", in: source, .php) == .variable) } @Test("comments: //, # and block comments") func comments() { #expect(role("// line comment", in: source, .php) == .comment) #expect(role("# hash", in: "\">\n\n hi\n\n" #expect(role("div", in: text, .php) == .number) #expect(role("$cls", in: text, .php) == .variable) #expect(role("?>", in: text, .php) == .keyword) #expect(role("if", in: text, .php) == .keyword) #expect(role("hi", in: text, .php) == .plain) #expect(role("endif", in: text, .php) == .keyword) } @Test("a PHP line comment ends at ?>") func lineCommentEndsAtCloseTag() { let text = "

after

" #expect(role("// note ", in: text, .php) == .comment) #expect(role("?>", in: text, .php) == .keyword) #expect(role("after", in: text, .php) == .plain) } @Test("a Blade file without name }}\n@endif" #expect(role("$user", in: text, .php) == .variable) } @Test("static, self and parent stay keywords before ::") func scopeKeywords() { let text = "