FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add tests · blacknode404/language-ruby@45c0f1b · GitHub

Repository navigation

Commit 45c0f1b

Browse files
committed
Add tests
1 parent 9c10254 commit 45c0f1b

2 files changed

Lines changed: 63 additions & 6 deletions

File tree

‎grammars/tree-sitter-ruby.cson‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,10 @@ scopes:
120120
'"while"': 'keyword.control'
121121
'"in"': 'keyword.control'
122122
'"until"': 'keyword.control'
123-
'"alias"': 'keyword.control'
124123
'"defined?"': 'keyword.control'
125-
'"redo"': 'keyword.control'
126-
'"super"': 'keyword.control'
124+
'"alias"': 'keyword.control'
127125
'"undef"': 'keyword.control'
128-
'"alias_method"': 'keyword.control'
129-
'"block_given?"': 'keyword.control'
130-
'"iterator?"': 'keyword.control'
126+
'super': 'keyword.control'
131127

132128
'interpolation': 'embedded.source'
133129
'interpolation > "#{"': 'punctuation.section.embedded'
@@ -149,6 +145,10 @@ scopes:
149145
match: '^(public|protected|private)$'
150146
scopes: 'keyword.other.special-method'
151147
}
148+
{
149+
match: '^(block_given\?|iterator\?|alias_method|redo)'
150+
scopes: 'keyword.control'
151+
}
152152
]
153153

154154
'escape_sequence': 'constant.character.escape'
@@ -167,6 +167,7 @@ scopes:
167167
'method_call > identifier:nth-child(0)': [
168168
{exact: 'require', scopes: 'support.function'}
169169
{match: '^(public|protected|private)$', scopes: 'keyword.other.special-method'}
170+
{match: '^(block_given\?|iterator\?|alias_method|redo)', scopes: 'keyword.control'}
170171
'entity.name.function'
171172
]
172173

‎spec/tree-sitter-spec.js‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,60 @@ describe('Tree-sitter Ruby grammar', () => {
5555
'.source.ruby .keyword.other.special-method'
5656
)
5757
})
58+
59+
it('tokenizes keyword predicates', async () => {
60+
const editor = await atom.workspace.open('foo.rb')
61+
62+
editor.setText(dedent`
63+
defined?(:thing)
64+
block_given?
65+
iterator?
66+
`)
67+
68+
expect(editor.scopeDescriptorForBufferPosition([0, 0]).toString()).toBe(
69+
'.source.ruby .keyword.control'
70+
)
71+
expect(editor.scopeDescriptorForBufferPosition([1, 0]).toString()).toBe(
72+
'.source.ruby .keyword.control'
73+
)
74+
expect(editor.scopeDescriptorForBufferPosition([2, 0]).toString()).toBe(
75+
'.source.ruby .keyword.control'
76+
)
77+
})
78+
79+
it('tokenizes alias definitions', async () => {
80+
const editor = await atom.workspace.open('foo.rb')
81+
82+
editor.setText(dedent`
83+
alias_method :name, :full_name
84+
alias name full_name
85+
`)
86+
87+
expect(editor.scopeDescriptorForBufferPosition([0, 0]).toString()).toBe(
88+
'.source.ruby .keyword.control'
89+
)
90+
expect(editor.scopeDescriptorForBufferPosition([1, 0]).toString()).toBe(
91+
'.source.ruby .keyword.control'
92+
)
93+
})
94+
95+
it('tokenizes keywords', async () => {
96+
const editor = await atom.workspace.open('foo.rb')
97+
98+
editor.setText(dedent`
99+
undef
100+
redo
101+
super
102+
`)
103+
104+
expect(editor.scopeDescriptorForBufferPosition([0, 0]).toString()).toBe(
105+
'.source.ruby .keyword.control'
106+
)
107+
expect(editor.scopeDescriptorForBufferPosition([1, 0]).toString()).toBe(
108+
'.source.ruby .keyword.control'
109+
)
110+
expect(editor.scopeDescriptorForBufferPosition([2, 0]).toString()).toBe(
111+
'.source.ruby .keyword.control'
112+
)
113+
})
58114
})

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL