Add test coverage for egg.py - #22
Conversation
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
hzhangxyz
left a comment
There was a problem hiding this comment.
大部分测试常见都是不对的,应该有的测试是
fact a = b, idea b = a,egg可以得到fact b = a
已知a=b,b=c,idea a=c,egg可以得到a=c
x=y,期望f(x)=f(y),egg可以得到
x = f(x),期望g(a) = g(f(a)) 可以得到(`表示变量)
已知f(x),已知x=y,期望f(y),可以满足
已知 x=y,y=z,f(x),期望f(z)可以满足
......
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
I've rewritten the tests to properly validate egraph equality saturation behavior as you specified. The new tests cover:
All tests pass. Commit: 8537b16 |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive test coverage for the egg.py module, which implements egraph-based equality saturation. The tests validate core egraph operations following the established testing pattern from test_output.py.
Key Changes:
- Created 6 test cases covering symmetry, transitivity, congruence, substitution (simple and chained), and cancellation behavior
- Implemented async test patterns with proper resource management and timeout handling
- Used the same
temp_dbfixture structure as existing tests for consistency
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| task.cancel() | ||
| try: | ||
| await task | ||
| except asyncio.CancelledError: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| task.cancel() | ||
| try: | ||
| await task | ||
| except asyncio.CancelledError: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| task.cancel() | ||
| try: | ||
| await task | ||
| except asyncio.CancelledError: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| task.cancel() | ||
| try: | ||
| await task | ||
| except asyncio.CancelledError: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| task.cancel() | ||
| try: | ||
| await task | ||
| except asyncio.CancelledError: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| # Should complete without hanging | ||
| try: | ||
| await task | ||
| except asyncio.CancelledError: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
The issue requested test coverage for
egg.pyfollowing the pattern established intest_output.py.Changes
Created
tests/test_egg.pywith 6 test cases validating egraph equality saturation behavior:Tests mirror
test_output.pystructure:temp_dbfixture with temporary SQLite databaseengine.dispose()The tests validate core egraph operations including equality properties (symmetry, transitivity), congruence closure, and term substitution based on equality relationships.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.