Skip to content

Commit e625ac4

Browse files
committed
Add basic test
1 parent 254bb8d commit e625ac4

File tree

5 files changed

+104
-1
lines changed

5 files changed

+104
-1
lines changed

pyproject.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ dependencies = [
1010
]
1111

1212
[tool.ruff]
13-
exclude = ["generated"]
13+
exclude = ["generated"]
14+
15+
[dependency-groups]
16+
dev = [
17+
"pytest>=8.3.3",
18+
]

test_main.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typer.testing import CliRunner
2+
from main import app
3+
4+
runner = CliRunner()
5+
6+
7+
def test_ast():
8+
result = runner.invoke(app, ["ast", "tests/ast/input_1.txt"])
9+
assert result.exit_code == 0
10+
with open("tests/ast/output_1.txt", encoding="utf-8") as f:
11+
output = f.read()
12+
assert result.stdout == output

tests/ast/input_1.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
A = zeros(3); # create 3x3 matrix filled with zeros
2+
B = ones(3); # create 3x3 matrix filled with ones
3+
C = eye(4); # create 4x4 diagonal matrix filled with ones
4+
5+
M = [
6+
[ 1, 2, 3],
7+
[ 4, 5, 6],
8+
[ 7, 8, 9]
9+
];

tests/ast/output_1.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
=
2+
| A
3+
| zeros
4+
| | 3
5+
=
6+
| B
7+
| ones
8+
| | 3
9+
=
10+
| C
11+
| eye
12+
| | 4
13+
=
14+
| M
15+
| vector
16+
| | vector
17+
| | | 1
18+
| | | 2
19+
| | | 3
20+
| | vector
21+
| | | 4
22+
| | | 5
23+
| | | 6
24+
| | vector
25+
| | | 7
26+
| | | 8
27+
| | | 9

uv.lock

+50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)