import HelderCore import Testing @Suite struct ShellGrammarTests { @Test("keywords, builtins, variables and strings") func basics() { let text = "if [ -n \"$HOME\" ]; then echo \"dir: ${HOME}/x\" 'no $sub'; fi" #expect(role("if", in: text, .bash) == .keyword) #expect(role("$HOME", in: text, .bash) == .variable) #expect(role("echo", in: text, .bash) == .number) #expect(role("${HOME}", in: text, .bash) == .variable) #expect(role("'no $sub'", in: text, .bash) == .string) #expect(role("fi", in: text, .bash) == .keyword) } @Test("a hash inside a word is not a comment") func hashInWord() { let text = "echo a#b # real" #expect(role("a#b", in: text, .bash) == .plain) #expect(role("# real", in: text, .bash) == .comment) } @Test("a heredoc runs to its marker; a quoted marker turns interpolation off") func heredoc() { let text = "cat <