trueagi-io / hyperon-experimental

MeTTa programming language implementation
https://metta-lang.dev
MIT License
141 stars 47 forks source link

AssertEqual[toResult] may analyze difference in detail #654

Open Necr0x0Der opened 6 months ago

Necr0x0Der commented 6 months ago

AssertEqual and AssertEqualtoResult may show that two expressions are different, when they are seemingly the same. This happens, for example, when a number is returned as a symbol by some operation and compared to a grounded number.

This can be reproduced in Python, e.g.

from hyperon import MeTTa, S, E
m = MeTTa()
m.space().add_atom(E(S("A"), S("2")))
print(m.run("! (assertEqual (match &self (A $x) $x) 2)"))

It will print

Expected: [2]
Got: [2]
Missed result: 2

It would be useful if asserts analyze the situation deeper. They make show excessive both expected and actual results, and either analyze their difference in more detail, or show the results in more detail.