Skip to content

Commit

Permalink
test: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Dec 9, 2023
1 parent 021f33b commit 38cd37b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ edition = "2021"
repository = "https://github.com/mtshiba/pylyzer"

[workspace.dependencies]
erg_common = { version = "0.6.27-nightly.0", features = ["py_compat", "els"] }
erg_compiler = { version = "0.6.27-nightly.0", features = ["py_compat", "els"] }
els = { version = "0.1.39-nightly.0", features = ["py_compat"] }
erg_common = { version = "0.6.27-nightly.1", features = ["py_compat", "els"] }
erg_compiler = { version = "0.6.27-nightly.1", features = ["py_compat", "els"] }
els = { version = "0.1.39-nightly.1", features = ["py_compat"] }
rustpython-parser = { version = "0.3.0", features = ["all-nodes-with-ranges", "location"] }
rustpython-ast = { version = "0.3.0", features = ["all-nodes-with-ranges", "location"] }
# rustpython-parser = { git = "https://github.com/RustPython/Parser", version = "0.3.0", features = ["all-nodes-with-ranges", "location"] }
Expand Down
2 changes: 2 additions & 0 deletions tests/class.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def __init__(self, c):
class E(D):
def __add__(self, other: E):
return E(self.c + other.c)
def invalid(self):
return self.d # ERR: E object has no attribute `d`

c1 = D(1).c + 1
d = D(1) + D(2)
Expand Down
23 changes: 23 additions & 0 deletions tests/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,26 @@ def call_method(obj, x):
assert call_method(c, 1) == "a" # ERR
print(call_method(1, 1)) # ERR
print(call_method(c)) # ERR

def x_and_y(a):
z: int = a.y
return a.x + z

class A:
x: int
y: int

def __init__(self, x, y):
self.x = x
self.y = y

class B:
x: int

def __init__(self, x):
self.x = x

a = A(1, 2)
assert x_and_y(a) == 3
b = B(3)
_ = x_and_y(b) # ERR: B object has no attribute `y`
4 changes: 2 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn exec_func() -> Result<(), String> {

#[test]
fn exec_class() -> Result<(), String> {
expect("tests/class.py", 0, 4)
expect("tests/class.py", 0, 5)
}

#[test]
Expand All @@ -96,7 +96,7 @@ fn exec_typespec() -> Result<(), String> {

#[test]
fn exec_projection() -> Result<(), String> {
expect("tests/projection.py", 0, 4)
expect("tests/projection.py", 0, 5)
}

#[test]
Expand Down

0 comments on commit 38cd37b

Please sign in to comment.