-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support r# strings in rust * CHANGELOG entry for r# rust string support
- Loading branch information
1 parent
9ae8b77
commit 42bb67a
Showing
3 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import assert from 'assert' | ||
|
||
import { stringLiteral } from '../../src/language/rustLanguage.js' | ||
import { TreeSitterSyntaxNode } from '../../src/language/types.js' | ||
|
||
describe('rustLanguage', () => { | ||
it('should extract string literal pattern', () => { | ||
const cases = [ | ||
{ | ||
input: '"the bee\'s knees"', | ||
expected: "the bee's knees", | ||
}, | ||
{ | ||
input: '"a {uuid}"', | ||
expected: 'a {uuid}', | ||
}, | ||
{ | ||
input: 'r"^a regexp$"', | ||
expected: '^a regexp$', | ||
}, | ||
{ | ||
// eslint-disable-next-line | ||
input: 'r"^stream (\w+) field (\w+) is a key$"', | ||
// eslint-disable-next-line | ||
expected: '^stream (\w+) field (\w+) is a key$', | ||
}, | ||
{ | ||
input: 'r#"I have cucumber in my belly"#', | ||
expected: 'I have cucumber in my belly', | ||
}, | ||
] | ||
|
||
cases.forEach(({ input, expected }) => { | ||
const node: TreeSitterSyntaxNode = { | ||
type: '', | ||
text: input, | ||
children: [], | ||
startPosition: { row: 0, column: 0 }, | ||
endPosition: { row: 0, column: 0 }, | ||
} | ||
assert.strictEqual(stringLiteral(node), expected) | ||
}) | ||
}) | ||
}) |