-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bindings): add node, python, swift tests
- Loading branch information
1 parent
8e8648a
commit 472f4d6
Showing
7 changed files
with
129 additions
and
50 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 was deleted.
Oops, something went wrong.
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,9 @@ | ||
/// <reference types="node" /> | ||
|
||
const assert = require("node:assert"); | ||
const { test } = require("node:test"); | ||
|
||
test("can load grammar", () => { | ||
const parser = new (require("tree-sitter"))(); | ||
assert.doesNotThrow(() => parser.setLanguage(require("."))); | ||
}); |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ node_modules/ | |
|
||
# Swift artifacts | ||
.build/ | ||
Package.resolved | ||
|
||
# Go artifacts | ||
go.sum | ||
|
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,60 @@ | ||
// swift-tools-version:5.3 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "TreeSitterCAMEL_PARSER_NAME", | ||
products: [ | ||
.library(name: "TreeSitterCAMEL_PARSER_NAME", targets: ["TreeSitterCAMEL_PARSER_NAME"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", from: "0.8.0"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "TreeSitterCAMEL_PARSER_NAME", | ||
dependencies: [], | ||
path: ".", | ||
exclude: [ | ||
"Cargo.toml", | ||
"Makefile", | ||
"binding.gyp", | ||
"bindings/c", | ||
"bindings/go", | ||
"bindings/node", | ||
"bindings/python", | ||
"bindings/rust", | ||
"prebuilds", | ||
"grammar.js", | ||
"package.json", | ||
"package-lock.json", | ||
"pyproject.toml", | ||
"setup.py", | ||
"test", | ||
"examples", | ||
".editorconfig", | ||
".github", | ||
".gitignore", | ||
".gitattributes", | ||
".gitmodules", | ||
], | ||
sources: [ | ||
"src/parser.c", | ||
// NOTE: if your language has an external scanner, add it here. | ||
], | ||
resources: [ | ||
.copy("queries") | ||
], | ||
publicHeadersPath: "bindings/swift", | ||
cSettings: [.headerSearchPath("src")] | ||
), | ||
.testTarget( | ||
name: "TreeSitterCAMEL_PARSER_NAMETests", | ||
dependencies: [ | ||
"SwiftTreeSitter", | ||
"TreeSitterCAMEL_PARSER_NAME", | ||
], | ||
path: "bindings/swift/TreeSitterCAMEL_PARSER_NAMETests" | ||
) | ||
], | ||
cLanguageStandard: .c11 | ||
) |
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,11 @@ | ||
from unittest import TestCase | ||
|
||
import tree_sitter, tree_sitter_LOWER_PARSER_NAME | ||
|
||
|
||
class TestLanguage(TestCase): | ||
def test_can_load_grammar(self): | ||
try: | ||
tree_sitter.Language(tree_sitter_LOWER_PARSER_NAME.language()) | ||
except Exception: | ||
self.fail("Error loading CAMEL_PARSER_NAME grammar") |
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,12 @@ | ||
import XCTest | ||
import SwiftTreeSitter | ||
import TreeSitterCAMEL_PARSER_NAME | ||
|
||
final class TreeSitterCAMEL_PARSER_NAMETests: XCTestCase { | ||
func testCanLoadGrammar() throws { | ||
let parser = Parser() | ||
let language = Language(language: tree_sitter_LOWER_PARSER_NAME()) | ||
XCTAssertNoThrow(try parser.setLanguage(language), | ||
"Error loading CAMEL_PARSER_NAME grammar") | ||
} | ||
} |