-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
415 additions
and
13 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
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,36 @@ | ||
import importlib.resources | ||
from unittest import TestCase | ||
|
||
from tree_sitter import Language, Parser, Tree | ||
|
||
try: | ||
import wasmtime | ||
|
||
class TestWasm(TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
javascript_wasm = ( | ||
importlib.resources.files("tests") | ||
.joinpath("wasm/tree-sitter-javascript.wasm") | ||
.read_bytes() | ||
) | ||
engine = wasmtime.Engine() | ||
cls.javascript = Language.from_wasm("javascript", engine, javascript_wasm) | ||
|
||
def test_parser(self): | ||
parser = Parser(self.javascript) | ||
self.assertIsInstance(parser.parse(b"test"), Tree) | ||
|
||
def test_language_is_wasm(self): | ||
self.assertEqual(self.javascript.is_wasm, True) | ||
|
||
except ImportError: | ||
|
||
class TestWasmDisabled(TestCase): | ||
def test_parser(self): | ||
def runtest(): | ||
Language.from_wasm("javascript", None, b"") | ||
|
||
self.assertRaisesRegex( | ||
RuntimeError, "wasmtime module is not loaded", runtest | ||
) |
Binary file not shown.
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
Oops, something went wrong.