-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
118 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
from complexipy import rust | ||
import unittest | ||
from pathlib import Path | ||
|
||
|
||
class TestFiles(unittest.TestCase): | ||
local_path = Path(__file__).resolve().parent | ||
|
||
def test_path(self): | ||
path = self.local_path / "src" | ||
files = rust.main(path.resolve().as_posix(), True, False, 0) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(40, total_complexity) | ||
|
||
def test(self): | ||
path = self.local_path / "src/test.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(9, total_complexity) | ||
|
||
def test_break_continue(self): | ||
path = self.local_path / "src/test_break_continue.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(3, total_complexity) | ||
|
||
def test_decorator(self): | ||
path = self.local_path / "src/test_decorator.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(1, total_complexity) | ||
|
||
def test_for(self): | ||
path = self.local_path / "src/test_for.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(5, total_complexity) | ||
|
||
def test_for_assign(self): | ||
path = self.local_path / "src/test_for_assign.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(1, total_complexity) | ||
|
||
def test_if(self): | ||
path = self.local_path / "src/test_if.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(3, total_complexity) | ||
|
||
def test_main(self): | ||
path = self.local_path / "src/test_main.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(0, total_complexity) | ||
|
||
def test_match(self): | ||
path = self.local_path / "src/test_match.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(0, total_complexity) | ||
|
||
def test_multiple_func(self): | ||
path = self.local_path / "src/test_multiple_func.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(0, total_complexity) | ||
|
||
def test_nested_func(self): | ||
path = self.local_path / "src/test_nested_func.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(2, total_complexity) | ||
|
||
def test_recursive(self): | ||
path = self.local_path / "src/test_recursive.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(0, total_complexity) | ||
|
||
def test_ternary_op(self): | ||
path = self.local_path / "src/test_ternary_op.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(1, total_complexity) | ||
|
||
def test_try(self): | ||
path = self.local_path / "src/test_try.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(3, total_complexity) | ||
|
||
def test_try_nested(self): | ||
path = self.local_path / "src/test_try_nested.py" | ||
files = rust.main(path.resolve().as_posix(), False, False, 15) | ||
total_complexity = sum([file.complexity for file in files]) | ||
self.assertEqual(12, total_complexity) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
def test_for(n: int): | ||
lst = [i for i in range(n)] | ||
|
||
for i in lst: | ||
print(i) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.