Page Menu
Home
Xreate
Search
Configure Global Search
Log In
Docs
Questions
Repository
Issues
Patches
Internal API
Files
F4822834
transcend.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Aug 24, 6:21 PM
Size
2 KB
Mime Type
text/x-c++
Expires
Wed, Aug 26, 6:21 PM (1 d, 6 h)
Engine
blob
Format
Raw Data
Handle
285286
Attached To
rXR Xreate
transcend.cpp
View Options
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*
* Author: pgess <v.melnychenko@xreate.org>
* Created on June 7, 2018, 3:35 PM
*
* \file transcend.cpp
* \brief Transcend's tests
*/
#include "xreatemanager.h"
#include "transcendlayer.h"
#include "supplemental/docutils.h"
#include <gtest/gtest.h>
using namespace xreate;
using namespace std;
TEST(Transcend, Parse1) {
std::string script =
R"Code(
)Code";
std::unique_ptr<details::tier1::XreateManager> man(details::tier1::XreateManager::prepare(std::move(script)));
std::string scriptTranscend =
R"Code(
test1((1)).
test2((1, 2)).
)Code";
man->transcend->addRawScript(move(scriptTranscend));
man->analyse();
StaticModel solution = man->transcend->query("test1");
Gringo::Symbol symbTest1 = solution.begin()->second;
auto answer1 = man->transcend->parse<list<int>>(symbTest1);
ASSERT_EQ(1, get<0>(answer1).size());
solution = man->transcend->query("test2");
Gringo::Symbol symbTest2 = solution.begin()->second;
auto answer2 = get<0>(man->transcend->parse<list<int>>(symbTest2));
ASSERT_EQ(2, answer2.size());
}
TEST(Transcend, Doc_Expressions1) {
string code = getDocumentationExampleById("documentation/Transcend/transcend.xml", "Expressions1");
XreateManager* man = XreateManager::prepare(move(code));
man->run();
delete man;
ASSERT_TRUE(true);
}
TEST(Transcend, Doc_SlaveTypes1){
string code = getDocumentationExampleById("documentation/Transcend/transcend.xml", "Codeblocks1");
XreateManager::prepare(move(code));
ASSERT_TRUE(true);
}
TEST(Transcend, Doc_Codeblocks1) {
string code = getDocumentationExampleById("documentation/Transcend/transcend.xml", "Codeblocks1");
XreateManager::prepare(move(code));
ASSERT_TRUE(true);
}
TEST(Transcend, Doc_Diagnostics1) {
string code = getDocumentationExampleById("documentation/Transcend/transcend.xml", "Diagnostics1");
string scriptTranscend = getDocumentationExampleById("documentation/Transcend/transcend.xml", "Diagnostics1_Rules");
string scriptSupport =
R"Code(
scope_func_dict(S, Fn):-
cfa_parent(S, function(Fn)).
scope_func_dict(S1, Fn):-
cfa_parent(S1, scope(S2));
scope_func_dict(S2, Fn).
)Code";
auto man = XreateManager::prepare(move(code));
man->transcend->addRawScript(move(scriptTranscend));
man->transcend->addRawScript(move(scriptSupport));
testing::internal::CaptureStdout();
man->run();
delete man;
std::string outputActual = testing::internal::GetCapturedStdout();
string outputExpected = "warning(\"Visibility violation\",test,sum)";
ASSERT_NE(std::string::npos, outputActual.find(outputExpected));
}
Event Timeline
Log In to Comment