Skip to content

Commit

Permalink
Merge pull request #19 from neilccbrown/master
Browse files Browse the repository at this point in the history
Fix NPE and add tests
  • Loading branch information
Tobias-Kohn authored Jan 3, 2025
2 parents e8a6738 + 41cf47b commit 758007a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ object ModuleLoader {

if (item.contains('(')) {
val b = if (curClass != null) PythonFunction.fromString(item, curClass, module.getFields) else BuiltinFunction.fromString(item, module.getFields)
curTarget.setField(b.name, b)
if (b != null) {
curTarget.setField(b.name, b)
}
} else
if (item != null && item != "") {
if (item.startsWith("[")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# parent1.child1.shape1
# class Shape:
# pos_x
# pos_y
# __init__(self, x, y)
# draw(self)
# extent(self)
# rotate_by(self, degrees)
# [Shape]make_shape()
# 49
# degrees
from parent1.child1.shape1 import *
make_shape().rotate_by()
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# parent2.child2.shape2
# class Shape:
# pos_x
# pos_y
# __init__(self, x, y)
# draw(self)
# extent(self)
# rotate_by(self, degrees)
# [Shape]make_shape(shape_type, shape_colour)
# 36
# shape_type, shape_colour
from parent2.child2.shape2 import *
make_shape()
11 changes: 11 additions & 0 deletions tpParser/shared/src/test/scala/TestCompleter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,15 @@ class TestCompleter extends FunSuite {
val suggestions = completer.getNameFilter.getNameList("").mkString(";")
assert(suggestions == expected_result)
}

for (fileName <- listAllFiles("completer_params"))
test("test program '%s'".format(getFileName(fileName))) {
val (pos, expected_result, text) = loadFromCompleterFile(fileName)
val completer = new Completer(fileName, text, pos)
val funcNameAtPos = text.drop(pos).takeWhile(_ != '(')
val params = completer.getNameFilter.getParams(funcNameAtPos)
assert(params == expected_result)
val extParams = completer.getNameFilter.getExtInfoList.filter(_.name == funcNameAtPos).map(_.parameters.mkString(", "))
assert(extParams sameElements Array(expected_result))
}
}

0 comments on commit 758007a

Please sign in to comment.