-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Test improvements (#3) * Improve tests slightly Add a slightly longer example * Continue writing tests * Fix formatting * Add try, except, finally to Python mapping * Add Java tests * Fix python mapping * Bump version to v0.1.0
- Loading branch information
Showing
11 changed files
with
994 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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
setup( | ||
name="albero", | ||
version="0.0.3", | ||
version="0.1.0", | ||
description="Albero is a tool that makes it much easier to use Tree Sitter for your code editors", | ||
author="Moosems", | ||
author_email="[email protected]", | ||
|
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,3 @@ | ||
# tests/test-langauges | ||
|
||
This folder aims to test that the mappings work the for the languages that have mappings |
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,107 @@ | ||
package com.example; | ||
|
||
import java.util.*; // Import statement | ||
|
||
/** | ||
* This is a block comment | ||
*/ | ||
|
||
public class Test { | ||
|
||
public static void main(String[] args) { | ||
// Line comment | ||
int a = 5; // decimal_integer_literal | ||
double b = 5.5; // decimal_floating_point_literal | ||
boolean isTrue = true; // boolean and true keyword | ||
boolean isFalse = false; // boolean and false keyword | ||
String str = "Hello, World!"; // String | ||
char c = 'A'; // character_literal | ||
char esc = '\n'; // escape_sequence | ||
|
||
a += 1; // += operator | ||
a -= 1; // -= operator | ||
a *= 2; // *= operator | ||
a /= 2; // /= operator | ||
a %= 2; // % operator | ||
a++; // ++ operator | ||
a--; // -- operator | ||
|
||
if (a == 5) { // if and == operator | ||
System.out.println("Equal to 5"); // Method call | ||
} else if (a != 5) { // else if and != operator | ||
System.out.println("Not equal to 5"); | ||
} else { // else keyword | ||
System.out.println("Something else"); | ||
} | ||
|
||
while (a < 10) { // while and < operator | ||
a++; // Increment | ||
} | ||
|
||
for (int i = 0; i < 10; i++) { // for loop and < operator | ||
System.out.println(i); // Method call | ||
} | ||
|
||
try { // try keyword | ||
throw new Exception("Error!"); // throw and new keyword | ||
} catch (Exception e) { // catch keyword | ||
e.printStackTrace(); // Method call | ||
} finally { // finally keyword | ||
System.out.println("Finally block"); | ||
} | ||
|
||
assert a == 10; // assert keyword and == operator | ||
|
||
switch (a) { | ||
case 10: // case keyword | ||
System.out.println("Case 10"); | ||
break; // break keyword | ||
default: | ||
System.out.println("Default case"); | ||
break; | ||
} | ||
|
||
boolean condition = a > 5 && a < 15; // && and <, > operators | ||
boolean orCondition = a > 5 || a < 15; // || operator | ||
|
||
Test test = new Test(); | ||
test.exampleMethod(); | ||
} | ||
|
||
public void exampleMethod() { | ||
super.toString(); // super keyword | ||
this.toString(); // this keyword | ||
} | ||
|
||
public interface ExampleInterface { // interface keyword | ||
void example(); // Method in interface | ||
} | ||
|
||
public abstract class ExampleAbstractClass { // abstract class | ||
public abstract void example(); // abstract method | ||
} | ||
|
||
public class ExampleClass extends ExampleAbstractClass implements ExampleInterface { // class, extends, implements keywords | ||
@Override | ||
public void example() { // @Override annotation | ||
// Method implementation | ||
} | ||
} | ||
|
||
private final int privateFinalVar = 1; // private, final keywords | ||
protected static int protectedStaticVar = 2; // protected, static keywords | ||
public int publicVar = 3; // public keyword | ||
|
||
public void returnVoid() { | ||
return; // return keyword | ||
} | ||
|
||
public int returnInt() { | ||
return 1; // return keyword with value | ||
} | ||
|
||
boolean notCondition = !isTrue; // ! operator | ||
boolean ternaryCondition = (a == 10) ? true : false; // ternary operator ? : | ||
|
||
int[] array = new int[]{1, 2, 3}; // array and new keyword | ||
} |
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,89 @@ | ||
from typing import Any | ||
|
||
from xyz import abc as efg # noqa: F401 | ||
|
||
# Example comment | ||
|
||
# Variables and literals | ||
u = {"x": "y\f"} # String with escape sequence | ||
v = 5.5 # float | ||
w = [] # list | ||
x = 5 # integer | ||
y = int("5") # integer from string | ||
z = lambda: print # lambda function # noqa: E731 | ||
|
||
# Control structures | ||
if x == 5: # if statement | ||
x += 5 + x # Addition and compound assignment | ||
x -= 5 - x # Subtraction and compound assignment | ||
x *= 2 * x # Multiplication and compound assignment | ||
x /= 2 / x # Division and compound assignment | ||
x **= 2**x # Exponentiation and compound assignment | ||
if x is not None: # is not | ||
pass # pass statement | ||
elif x is None: # elif and is | ||
pass | ||
else: # else | ||
pass | ||
|
||
# match-case statement | ||
match x: | ||
case 5: # case | ||
print("Nice") | ||
case _: # case _ | ||
print("Woah") | ||
|
||
# while loop and break statement | ||
while 2 in w: # in operator | ||
break | ||
if 2 not in w: # not in operator | ||
pass | ||
|
||
|
||
# Function with decorator | ||
def decorator(arg) -> Any: # Function definition and type hint | ||
def wrapper(): # Nested function | ||
return arg() # return statement | ||
|
||
return wrapper | ||
|
||
|
||
@decorator | ||
def example(): | ||
if x > y: # Greater than | ||
pass | ||
if x >= y: # Greater than or equal | ||
pass | ||
if x < y: # Less than | ||
pass | ||
if x <= y: # Less than or equal | ||
pass | ||
... | ||
if x or y: # Logical OR | ||
pass | ||
with open("xyz.foo") as l: # with statement and as # noqa: F841, E741 | ||
assert False == False # assert statement and equality # noqa: E712 | ||
assert True == True # noqa: E712 | ||
pass | ||
|
||
|
||
# Class with method | ||
class Foo: | ||
def break_func(self): | ||
raise Exception("NO") # raise statement | ||
|
||
|
||
# for loop and continue statement | ||
for i in range(x): | ||
continue | ||
|
||
# Dictionary merging (Python 3.9+) | ||
q = {} | {} # Dictionary merge operator | ||
|
||
# try-except-finally block | ||
try: | ||
pass | ||
except: # bare except # noqa: E722 | ||
pass | ||
finally: # finally | ||
pass |
Oops, something went wrong.