Add eqp (pointer equality) tests

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-07-21 15:59:10 -07:00
parent 9e966a0e57
commit f6e18045f3
2 changed files with 6 additions and 0 deletions

View file

@ -168,6 +168,8 @@ unsigned length(sexpr const & s) {
} }
bool operator==(sexpr const & a, sexpr const & b) { bool operator==(sexpr const & a, sexpr const & b) {
if (eqp(a, b))
return true;
sexpr::kind ka = a.get_kind(); sexpr::kind ka = a.get_kind();
sexpr::kind kb = b.get_kind(); sexpr::kind kb = b.get_kind();
if (ka != kb) if (ka != kb)

View file

@ -69,6 +69,10 @@ static void tst1() {
lean_assert(append(nil(), l) == l); lean_assert(append(nil(), l) == l);
lean_assert(contains(sexpr{10,20,-2,0,10}, [](sexpr e) { return to_int(e) < 0; })); lean_assert(contains(sexpr{10,20,-2,0,10}, [](sexpr e) { return to_int(e) < 0; }));
lean_assert(!contains(sexpr{10,20,-2,0,10}, [](sexpr e) { return to_int(e) < -10; })); lean_assert(!contains(sexpr{10,20,-2,0,10}, [](sexpr e) { return to_int(e) < -10; }));
lean_assert(eqp(s1, s1));
sexpr s3 = s1;
lean_assert(eqp(s1, s3));
lean_assert(!eqp(sexpr(1), sexpr(1)));
} }
static void tst2() { static void tst2() {