8000 embryo test for tuple binding · Z80coder/datalog-cpp@2c733cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c733cd

Browse files
committed
embryo test for tuple binding
1 parent 8bbc896 commit 2c733cd

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ add_executable(variable_test ../tests/variable_test.cpp)
3535
target_include_directories(variable_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
3636
target_link_libraries(variable_test tests_main)
3737
target_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)

src/Datalog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ namespace datalog
2020

2121
using 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+
6064
template <typename T>
6165
bool bind(const T &a, const T &b)
6266
{

src/tuple_binding.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace 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

tests/run_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
22
set -e
33
../build/types_test
4-
../build/variable_test
4+
../build/variable_test
5+
../build/tuple_binding_test

tests/tuple_binding_test.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

0 commit comments

Comments
 (0)
0