Commit 7059dcb6 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

Renamed jx9 functions

parent d021f1d1
......@@ -85,28 +85,28 @@ class UnQLiteVM {
int ret;
ret = unqlite_create_constant(m_vm, "__SCRIPT__", get_script, static_cast<void*>(this));
// Admin functions
ret = unqlite_create_function(m_vm, "snta_db_create", snta_db_create, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "snta_db_attach", snta_db_attach, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "snta_db_detach", snta_db_detach, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "snta_db_destroy", snta_db_destroy, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_db_create", snta_db_create, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_db_attach", snta_db_attach, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_db_detach", snta_db_detach, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_db_destroy", snta_db_destroy, static_cast<void*>(this));
// Database functions
ret = unqlite_create_function(m_vm, "sntd_coll_create", sntd_coll_create, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntd_coll_exists", sntd_coll_exists, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntd_coll_open", sntd_coll_open, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntd_coll_drop", sntd_coll_drop, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntd_execute", sntd_execute, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_coll_create", sntd_coll_create, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_coll_exists", sntd_coll_exists, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_coll_open", sntd_coll_open, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_coll_drop", sntd_coll_drop, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_execute", sntd_execute, static_cast<void*>(this));
// Collection functions
ret = unqlite_create_function(m_vm, "sntc_store", sntc_store, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntc_fetch", sntc_fetch, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntc_filter", sntc_filter, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntc_update", sntc_update, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntc_all", sntc_all, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntc_last_record_id", sntc_last_record_id, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntc_size", sntc_size, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntc_erase", sntc_erase, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_store", sntc_store, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_fetch", sntc_fetch, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_filter", sntc_filter, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_update", sntc_update, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_all", sntc_all, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_last_record_id", sntc_last_record_id, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_size", sntc_size, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_erase", sntc_erase, static_cast<void*>(this));
// Wait functions
ret = unqlite_create_function(m_vm, "sntr_wait", sntr_wait, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sntr_test", sntr_test, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_wait", sntr_wait, static_cast<void*>(this));
ret = unqlite_create_function(m_vm, "sonata_test", sntr_test, static_cast<void*>(this));
}
private:
......
$rc = TRUE;
print "Executing test on address ", $addr, "\n";
// Create a database
print "Executing snta_db_create test\n";
$rc = snta_db_create($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
print "Executing sonata_db_create test\n";
$rc = sonata_db_create($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
if($rc != TRUE) {
print "snta_db_create failed\n";
print "sonata_db_create failed\n";
$rc = FALSE;
return;
} else {
print "snta_db_create was successful\n";
print "sonata_db_create was successful\n";
}
// Detach the database
print "Executing snta_db_detach test\n";
$rc = snta_db_detach($addr, 0, "dbFromJx9");
print "Executing sonata_db_detach test\n";
$rc = sonata_db_detach($addr, 0, "dbFromJx9");
if($rc != TRUE) {
print "snta_db_detach failed\n";
print "sonata_db_detach failed\n";
$rc = FALSE;
return;
} else {
print "snta_db_detach was successful\n";
print "sonata_db_detach was successful\n";
}
// Attach the database
print "Executing snta_db_attach test\n";
$rc = snta_db_attach($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
print "Executing sonata_db_attach test\n";
$rc = sonata_db_attach($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
if($rc != TRUE) {
print "snta_db_attach failed\n";
print "sonata_db_attach failed\n";
$rc = FALSE;
return;
} else {
print "snta_db_attach was successful\n";
print "sonata_db_attach was successful\n";
}
// Destroy the database
print "Executing snta_db_destroy test\n";
$rc = snta_db_destroy($addr, 0, "dbFromJx9");
print "Executing sonata_db_destroy test\n";
$rc = sonata_db_destroy($addr, 0, "dbFromJx9");
if($rc != TRUE) {
print "snta_db_destroy failed\n";
print "sonata_db_destroy failed\n";
$rc = FALSE;
return;
} else {
print "snta_db_destroy was successful\n";
print "sonata_db_destroy was successful\n";
}
$rc = TRUE;
print "Executing test on address ", $addr, "\n";
print "Executing snta_db_attach test\n";
$rc = snta_db_attach($addr, 0, "dbFromJx9", "blabla", { path : "dbFromJx9" });
print "Executing sonata_db_attach test\n";
$rc = sonata_db_attach($addr, 0, "dbFromJx9", "blabla", { path : "dbFromJx9" });
if($rc != TRUE) {
print "snta_db_attach failed\n";
print "sonata_db_attach failed\n";
$rc = FALSE;
return;
} else {
print "snta_db_attach was successful\n";
print "sonata_db_attach was successful\n";
}
$rc = TRUE;
print "Executing test on address ", $addr, "\n";
// Create a database
print "Executing snta_db_create test\n";
$rc = snta_db_create($addr, 0, "dbFromJx9", "blabla", { path : "dbFromJx9" });
print "Executing sonata_db_create test\n";
$rc = sonata_db_create($addr, 0, "dbFromJx9", "blabla", { path : "dbFromJx9" });
if($rc != TRUE) {
print "snta_db_create failed\n";
print "sonata_db_create failed\n";
$rc = FALSE;
return;
} else {
print "snta_db_create was successful\n";
print "sonata_db_create was successful\n";
}
$rc = TRUE;
print "Executing test on address ", $addr, "\n";
print "Executing snta_db_destroy test\n";
$rc = snta_db_destroy($addr, 0, "blabla");
print "Executing sonata_db_destroy test\n";
$rc = sonata_db_destroy($addr, 0, "blabla");
if($rc != TRUE) {
print "snta_db_destroy failed\n";
print "sonata_db_destroy failed\n";
$rc = FALSE;
return;
} else {
print "snta_db_destroy was successful\n";
print "sonata_db_destroy was successful\n";
}
$rc = TRUE;
print "Executing test on address ", $addr, "\n";
print "Executing snta_db_detach test\n";
$rc = snta_db_detach($addr, 0, "blabla");
print "Executing sonata_db_detach test\n";
$rc = sonata_db_detach($addr, 0, "blabla");
if($rc != TRUE) {
print "snta_db_detach failed\n";
print "sonata_db_detach failed\n";
$rc = FALSE;
return;
} else {
print "snta_db_detach was successful\n";
print "sonata_db_detach was successful\n";
}
$rc = TRUE;
print "Executing test on address ", $addr, "\n";
$ret = snta_db_create($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
$ret = sonata_db_create($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
if($ret != TRUE) {
print "snta_db_create failed\n";
print "sonata_db_create failed\n";
$rc = FALSE;
return;
}
......@@ -13,100 +13,100 @@ $db = { database_name : "dbFromJx9",
provider_id : 0 };
print "Creating mycollection... ";
$coll_info = sntd_coll_create($db, "mycollection");
$coll_info = sonata_coll_create($db, "mycollection");
if($coll_info == NULL) {
print "snta_db_create failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_db_create failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Creating mycollection again (should fail)... ";
$coll_info = sntd_coll_create($db, "mycollection");
$coll_info = sonata_coll_create($db, "mycollection");
if($coll_info != NULL) {
print "snta_db_create was successful when it should have failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_db_create was successful when it should have failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Checking if mycollection exists... ";
$exists = sntd_coll_exists($db, "mycollection");
$exists = sonata_coll_exists($db, "mycollection");
if($exists != TRUE) {
print "sntd_coll_exists failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_coll_exists failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Checking if blabla exists (should fail)... ";
$exists = sntd_coll_exists($db, "blabla");
$exists = sonata_coll_exists($db, "blabla");
if($exists == TRUE) {
print "sntd_coll_exists was successful when it should have failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_coll_exists was successful when it should have failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Opening mycollection... ";
$coll_info = sntd_coll_open($db, "mycollection");
$coll_info = sonata_coll_open($db, "mycollection");
if($coll_info == NULL) {
print "sntd_coll_open failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_coll_open failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Opening blabla (should fail)... ";
$coll_info = sntd_coll_open($db, "blabla");
$coll_info = sonata_coll_open($db, "blabla");
if($coll_info != NULL) {
print "sntd_coll_open was successful when it should have failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_coll_open was successful when it should have failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Dropping mycollection... ";
$ret = sntd_coll_drop($db, "mycollection");
$ret = sonata_coll_drop($db, "mycollection");
if($ret != TRUE) {
print "sntd_coll_drop failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_coll_drop failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Checking if mycollection exists (should return FALSE)... ";
$exists = sntd_coll_exists($db, "mycollection");
$exists = sonata_coll_exists($db, "mycollection");
if($exists != FALSE) {
print "sntd_coll_exists returned TRUE for a collection that was erased\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_coll_exists returned TRUE for a collection that was erased\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Dropping blabla (should fail)... ";
$ret = sntd_coll_drop($db, "blabla");
$ret = sonata_coll_drop($db, "blabla");
if($ret == TRUE) {
print "sntd_coll_drop returned TRUE for a collection that did not exist\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_coll_drop returned TRUE for a collection that did not exist\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Destroying database dbFromJx9\n";
$rc = snta_db_destroy($addr, 0, "dbFromJx9");
$rc = sonata_db_destroy($addr, 0, "dbFromJx9");
if($rc != TRUE) {
print "snta_db_destroy failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_db_destroy failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
......
$rc = TRUE;
print "Executing test on address ", $addr, "\n";
$ret = snta_db_create($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
$ret = sonata_db_create($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
if($ret != TRUE) {
print "snta_db_create failed\n";
print "sonata_db_create failed\n";
$rc = FALSE;
return;
}
......@@ -19,10 +19,10 @@ function myfunction() {
print "blabla";
}
$results = sntd_execute($db, myfunction, ["a","__output__"]);
$results = sonata_execute($db, myfunction, ["a","__output__"]);
if($results == NULL) {
print "sntd_execute failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_execute failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
......@@ -30,19 +30,19 @@ print "OK\n";
$fcode = "\$a = 42; print \"blabla\";";
$results = sntd_execute($db, $fcode, ["a","__output__"]);
$results = sonata_execute($db, $fcode, ["a","__output__"]);
if($results == NULL) {
print "sntd_execute failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_execute failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Destroying database dbFromJx9\n";
$rc = snta_db_destroy($addr, 0, "dbFromJx9");
$rc = sonata_db_destroy($addr, 0, "dbFromJx9");
if($rc != TRUE) {
print "snta_db_destroy failed\n";
print "sonata_db_destroy failed\n";
$rc = FALSE;
return;
}
......
$rc = TRUE;
print "Executing test on address ", $addr, "\n";
$ret = snta_db_create($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
$ret = sonata_db_create($addr, 0, "dbFromJx9", "unqlite", { path : "dbFromJx9" });
if($ret != TRUE) {
print "snta_db_create failed\n";
print "sonata_db_create failed\n";
$rc = FALSE;
return;
}
......@@ -13,7 +13,7 @@ $db = { database_name : "dbFromJx9",
provider_id : 0 };
// Create a collection
$coll = sntd_coll_create($db, "mycollection");
$coll = sonata_coll_create($db, "mycollection");
$records = [
{ name : "John Lennon", year : 1940 },
......@@ -22,55 +22,55 @@ $records = [
{ name : "Peter Best", year : 1941 }
];
print "Testing sntc_store... ";
print "Testing sonata_store... ";
for($i = 0; $i < 4 ; $i++) {
$id = sntc_store($coll, $records[$i]);
$id = sonata_store($coll, $records[$i]);
if($id == NULL) {
print "sntd_store failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_store failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
}
print "OK\n";
print "Testing sntc_fetch... ";
print "Testing sonata_fetch... ";
for($i = 0; $i < 4 ; $i++) {
$r = sntc_fetch($coll, $i);
$r = sonata_fetch($coll, $i);
if($r == NULL) {
print "sntc_fetch failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_fetch failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
if($r.name != $records[$i].name) {
print "record field not matching\n";
snta_db_destroy($addr, 0, "dbFromJx9");
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
}
print "OK\n";
print "Testing sntc_all... ";
$r = sntc_all($coll);
print "Testing sonata_all... ";
$r = sonata_all($coll);
if($r == NULL) {
print "sntc_all failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_all failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
for($i = 0; $i < 4 ; $i++) {
if($r[$i].name != $records[$i].name) {
print "record field not matching\n";
snta_db_destroy($addr, 0, "dbFromJx9");
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
}
print "OK\n";
print "Testing sntc_filter... ";
print "Testing sonata_filter... ";
function myfilter($member) {
if($member.year > 1941) {
return TRUE;
......@@ -78,79 +78,79 @@ function myfilter($member) {
return FALSE;
}
}
$filtered = sntc_filter($coll, myfilter);
$filtered = sonata_filter($coll, myfilter);
if($filtered == NULL) {
print "sntc_filter failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_filter failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
if(count($filtered) != 2) {
print "unexpected number of returned records\n";
snta_db_destroy($addr, 0, "dbFromJx9");
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Testing sntc_size... ";
$size = sntc_size($coll);
print "Testing sonata_size... ";
$size = sonata_size($coll);
if($size != 4) {
print "sntc_size failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_size failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Testing sntc_last_record_id... ";
$id = sntc_last_record_id($coll);
print "Testing sonata_last_record_id... ";
$id = sonata_last_record_id($coll);
if($id != 3) {
print "sntc_last_record_id failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_last_record_id failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Testing sntc_update... ";
$ret = sntc_update($coll, 3, { "name" : "Ringo Starr", "year" : 1940 });
print "Testing sonata_update... ";
$ret = sonata_update($coll, 3, { "name" : "Ringo Starr", "year" : 1940 });
if($r == NULL) {
print "sntc_update failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_update failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
$new_record = sntc_fetch($coll, 3);
$new_record = sonata_fetch($coll, 3);
if($new_record.name != "Ringo Starr") {
print "recod not matching after update\n";
snta_db_destroy($addr, 0, "dbFromJx9");
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Testing sntc_erase... ";
$ret = sntc_erase($coll, 0);
print "Testing sonata_erase... ";
$ret = sonata_erase($coll, 0);
if($ret == NULL) {
print "sntc_erase failed\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_erase failed\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
$record0 = sntc_fetch($coll, 0);
$record0 = sonata_fetch($coll, 0);
if($record0 != NULL) {
print "sntc_fetch returned a result when it shouldn't have\n";
snta_db_destroy($addr, 0, "dbFromJx9");
print "sonata_fetch returned a result when it shouldn't have\n";
sonata_db_destroy($addr, 0, "dbFromJx9");
$rc = FALSE;
return;
}
print "OK\n";
print "Destroying database dbFromJx9\n";
$rc = snta_db_destroy($addr, 0, "dbFromJx9");
$rc = sonata_db_destroy($addr, 0, "dbFromJx9");
if($rc != TRUE) {
print "snta_db_destroy failed\n";
print "sonata_db_destroy failed\n";
$rc = FALSE;
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment