File tree Expand file tree Collapse file tree 5 files changed +36
-2
lines changed
Expand file tree Collapse file tree 5 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,9 @@ add_executable(variable_test ../tests/variable_test.cpp)
3535target_include_directories (variable_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )
3636target_link_libraries (variable_test tests_main)
3737target_compile_definitions (variable_test PUBLIC UNIX )
38+
39+ # tuple_binding_test target
40+ add_executable (tuple_binding_test ../tests/tuple_binding_test.cpp)
41+ target_include_directories (tuple_binding_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )
42+ target_link_libraries (tuple_binding_test tests_main)
43+ target_compile_definitions (tuple_binding_test PUBLIC UNIX )
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ namespace datalog
2020
2121using namespace std ;
2222
23+ // High-level API functions
24+
2325/* *
2426 * @brief create a new variable
2527 *
@@ -57,6 +59,8 @@ void deleteVar(Variable<T> *v)
5759 delete v;
5860}
5961
62+ // TODO: all functions below here to be refactored into separate files
63+
6064template <typename T>
6165bool bind (const T &a, const T &b)
6266{
Original file line number Diff line number Diff line change 55
66namespace datalog {
77
8+ // TODO: reify the concept of a tuple of values and pointers to Variables
9+
810/* *
911 * @brief unbind a variable
1012 *
@@ -18,7 +20,7 @@ void unbind(Variable<T> *t)
1820}
1921
2022/* *
21- * @brief unbind no-operation for types that are not variables
23+ * @brief unbind no-operation for types that are not variables (i.e. values)
2224 *
2325 * @tparam T
2426 * @param t
Original file line number Diff line number Diff line change 11#! /bin/bash
22set -e
33../build/types_test
4- ../build/variable_test
4+ ../build/variable_test
5+ ../build/tuple_binding_test
Original file line number Diff line number Diff line change 1+ #include " catch.hpp"
2+ #include " Datalog.h"
3+
4+ using namespace datalog ;
5+ using namespace std ;
6+
7+ bool unbindTest ()
8+ {
9+ auto v = var<int >();
10+ v->bind (3 );
11+ tuple<decltype (v), int > t{v, 3 };
12+ v->unbind ();
13+ bool returnVal = !get<0 >(t)->isBound ();
14+ deleteVar (v);
15+ return returnVal;
16+ }
17+
18+ TEST_CASE (" tuple binding test" , " [tuple-binding]" )
19+ {
20+ REQUIRE (unbindTest ());
21+ }
You can’t perform that action at this time.
0 commit comments