Add head_beta tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
e7487a1fec
commit
f08c06d582
3 changed files with 47 additions and 0 deletions
|
@ -104,4 +104,5 @@ add_subdirectory(tests/util)
|
|||
add_subdirectory(tests/util/numerics)
|
||||
add_subdirectory(tests/interval)
|
||||
add_subdirectory(tests/kernel)
|
||||
add_subdirectory(tests/library)
|
||||
add_subdirectory(tests/frontends/lean)
|
||||
|
|
3
src/tests/library/CMakeLists.txt
Normal file
3
src/tests/library/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
add_executable(beta beta.cpp)
|
||||
target_link_libraries(beta ${EXTRA_LIBS})
|
||||
add_test(beta ${CMAKE_CURRENT_BINARY_DIR}/beta)
|
43
src/tests/library/beta.cpp
Normal file
43
src/tests/library/beta.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#include "test.h"
|
||||
#include "beta.h"
|
||||
#include "abstract.h"
|
||||
#include "printer.h"
|
||||
using namespace lean;
|
||||
|
||||
static void tst1() {
|
||||
expr f = Const("f");
|
||||
expr g = Const("g");
|
||||
expr x = Const("x");
|
||||
expr y = Const("y");
|
||||
expr z = Const("z");
|
||||
expr A = Const("A");
|
||||
expr a = Const("a");
|
||||
expr b = Const("b");
|
||||
expr c = Const("c");
|
||||
expr d = Const("d");
|
||||
expr F = Fun({{x, A}, {y, A}, {z, A}}, f(x, g(y, x, z)));
|
||||
lean_assert(is_head_beta(F(a, b)));
|
||||
lean_assert(!is_head_beta(f(a,b)));
|
||||
lean_assert(!is_head_beta(Fun({x,A}, x)));
|
||||
std::cout << head_beta(F(a,b)) << "\n";
|
||||
lean_assert(head_beta(F(a,b)) == Fun({z, A}, f(a, g(b, a, z))));
|
||||
lean_assert(head_beta(F(a,b,c)) == f(a, g(b, a, c)));
|
||||
std::cout << head_beta(F(a,b,c,d)) << "\n";
|
||||
lean_assert(head_beta(F(a,b,c,d)) == mk_app(f(a, g(b, a, c)), d));
|
||||
lean_assert(head_beta(F(a)) == Fun({{y, A}, {z, A}}, f(a, g(y, a, z))));
|
||||
lean_assert(head_beta(F) == F);
|
||||
lean_assert(head_beta(f(a,b)) == f(a,b));
|
||||
lean_assert(head_beta(mk_app(Fun({x,A}, x), a, b)) == a(b));
|
||||
lean_assert(head_beta(mk_app(Fun({x,A}, x), a)) == a);
|
||||
}
|
||||
|
||||
int main() {
|
||||
tst1();
|
||||
return has_violations() ? 1 : 0;
|
||||
}
|
Loading…
Reference in a new issue