Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions integration_tests/test_gruntz.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@
from sympy import Symbol

def mmrv(e: S, x: S) -> list[S]:
l: list[S] = []
if not e.has(x):
return l
list0: list[S] = []
return list0
elif e == x:
list1: list[S] = [x]
return list1
else:
raise

def test_mrv1():
def test_mrv():
# Case 1
x: S = Symbol("x")
y: S = Symbol("y")
ans: list[S] = mmrv(y, x)
assert len(ans) == 0
ans1: list[S] = mmrv(y, x)
print(ans1)
assert len(ans1) == 0

test_mrv1()
# Case 2
ans2: list[S] = mmrv(x, x)
ele1: S = ans2[0]
print(ele1)
assert ele1 == x
assert len(ans2) == 1

test_mrv()
9 changes: 9 additions & 0 deletions src/libasr/pass/replace_symbolic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,15 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
xx.m_test = new_logical_not;
}
}
} else if (ASR::is_a<ASR::SymbolicCompare_t>(*xx.m_test)) {
ASR::SymbolicCompare_t *s = ASR::down_cast<ASR::SymbolicCompare_t>(xx.m_test);
ASR::expr_t* function_call = nullptr;
if (s->m_op == ASR::cmpopType::Eq) {
function_call = basic_compare(xx.base.base.loc, "basic_eq", s->m_left, s->m_right);
} else {
function_call = basic_compare(xx.base.base.loc, "basic_neq", s->m_left, s->m_right);
}
xx.m_test = function_call;
}
}

Expand Down