Skip to content

Commit

Permalink
Update inline tests for all cases (#394)
Browse files Browse the repository at this point in the history
* Update python files for testing

* update tests

* fix format
  • Loading branch information
paulacamargo25 authored Jul 22, 2024
1 parent 47a5cd8 commit 7b57e15
Show file tree
Hide file tree
Showing 5 changed files with 285 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class PythonInlineValueProvider implements InlineValuesProvider {
.map((variable: any) => variable.name);

let variableRegex = new RegExp(
'(?:self.)?' + //match self. if present
'(?:[a-zA-Z_][a-zA-Z0-9_]*\\.)*' + //match any number of variable names separated by '.'
'[a-zA-Z_][a-zA-Z0-9_]*', //math variable name
'g',
);
Expand All @@ -92,7 +92,7 @@ export class PythonInlineValueProvider implements InlineValuesProvider {
continue;
}
if (pythonVariables.includes(varName.split('.')[0])) {
if (varName.includes('self')) {
if (varName.includes('.')) {
const rng = new Range(l, match.index, l, match.index + varName.length);
allValues.push(new InlineValueEvaluatableExpression(rng, varName));
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/test/pythonFiles/testAssignmentExp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
some_list = [1, 2, 3, 7]
x = 3
if (n := len(some_list)) > x:
print(f"The length of some_list is {n}, which is greater than {x}.")
else:
print(f"The length of some_list is {n}, which is not greater than {x}.")
2 changes: 2 additions & 0 deletions src/test/pythonFiles/testClassVarType.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Person:
id = 1
def __init__(self, name, age):
self.name = name
self.age = age
Expand All @@ -8,3 +9,4 @@ def greet(self):

person1 = Person("John Doe", 30)
person1.greet()
person1.id = 3
5 changes: 2 additions & 3 deletions src/test/pythonFiles/testVarTypes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var1 = 5
var2 = 7
var1, var2 = 7, 6
var3 = "hola"
var4 = {"a": 1, "b": 2}
var5 = [1, 2, 3]
var6 =var1 + var2
var6 = var1 + var2
Loading

0 comments on commit 7b57e15

Please sign in to comment.