Skip to content

Commit

Permalink
Added assert to the test
Browse files Browse the repository at this point in the history
  • Loading branch information
tanay-man committed Aug 16, 2024
1 parent bb88bf5 commit 5ea94d0
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 33 deletions.
6 changes: 4 additions & 2 deletions integration_tests/class_06.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ def __init__(self:"Base"):
class Derived(Base):
pass

def f(i:Base):
def f(i:Base) -> i32:
print(i.x)
return i.x

def main():
d : Derived = Derived()
f(d)
op :i32 = f(d)
assert op == 10

main()
4 changes: 2 additions & 2 deletions tests/reference/asr-class_06-cdc5e29.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"basename": "asr-class_06-cdc5e29",
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
"infile": "tests/../integration_tests/class_06.py",
"infile_hash": "f6ac8d14e8dcd9e828294fdc9fa65f930eb30e65094f342cd296cfb2",
"infile_hash": "14c2deb888846d507958aaff8cca0de9ebb3514eb91e631ee38db582",
"outfile": null,
"outfile_hash": null,
"stdout": "asr-class_06-cdc5e29.stdout",
"stdout_hash": "26981374520cb1e14bfbc5b2fb349c66200d649a9f35bb110fc64287",
"stdout_hash": "c91e6e81e2ebbaf0d641e42fad2056b6069db42c53f1ed7a8b442b47",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
117 changes: 88 additions & 29 deletions tests/reference/asr-class_06-cdc5e29.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@
(SymbolTable
6
{
_lpython_return_variable:
(Variable
6
_lpython_return_variable
[]
ReturnVar
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
),
i:
(Variable
6
Expand Down Expand Up @@ -238,7 +254,7 @@
.false.
2 Base
)]
()
(Integer 4)
Source
Implementation
()
Expand All @@ -261,8 +277,19 @@
)]
()
()
)]
()
)
(Assignment
(Var 6 _lpython_return_variable)
(StructInstanceMember
(Var 6 i)
3 x
(Integer 4)
()
)
()
)
(Return)]
(Var 6 _lpython_return_variable)
Public
.false.
.false.
Expand Down Expand Up @@ -293,6 +320,22 @@
Public
Required
.false.
),
op:
(Variable
7
op
[]
Local
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
)
})
main
Expand Down Expand Up @@ -327,35 +370,51 @@
)
()
)
(SubroutineCall
2 f
()
[((Cast
(Var 7 d)
DerivedToBase
(StructType
[(Integer 4)]
[(FunctionType
[(Class
2 Base
(Assignment
(Var 7 op)
(FunctionCall
2 f
()
[((Cast
(Var 7 d)
DerivedToBase
(StructType
[(Integer 4)]
[(FunctionType
[(Class
2 Base
)]
()
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)]
()
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)]
.false.
2 Base
)
2 Base
)
()
))]
(Integer 4)
()
))]
()
)
()
)
(Assert
(IntegerCompare
(Var 7 op)
Eq
(IntegerConstant 10 (Integer 4))
(Logical 4)
()
)
()
)]
()
Expand Down

0 comments on commit 5ea94d0

Please sign in to comment.