CFGtests.cpp
No OneTemporary

File Metadata

Created
Tue, Jul 7, 4:13 PM

CFGtests.cpp

/*
* testsCFG.cpp
*
* Created on: Jul 17, 2015
* Author: pgess
*/
#include "passmanager.h"
#include "pass/dfgpass.h"
#include "gtest/gtest.h"
using namespace xreate;
using namespace std;
TEST(CFG, testFunctionAnnotationsClasp){
string&& program =
"f2 = function()::int; annotationF2 {\n"
" 0\n"
"}\n"
"\n"
"f1 = function():: int; entry; annotationF1 {\n"
" f2() + 10\n"
"}";
PassManager* man = PassManager::prepareForCode(move(program));
man->runWithoutCompilation();
ClaspLayer::ModelFragment answer = man->clasp->query("annotationF1");
int countNoneValue = 0;
if (answer)
countNoneValue = std::distance(answer->first, answer->second);
EXPECT_EQ(1, countNoneValue);
answer = man->clasp->query("annotationF2");
countNoneValue = 0;
if (answer)
countNoneValue = std::distance(answer->first, answer->second);
EXPECT_EQ(1, countNoneValue);
}
TEST(CFG, testLoopContextExists){
PassManager* man = PassManager::prepareForCode (
"interface(cfa){\n"
" operator fold:: annotation1.\n"
"}\n"
"\n"
"main = function() :: int; entry {\n"
" x = [1..10]:: [int].\n"
" sum = loop fold (x->el:: int, 0->sum:: int):: [int] {\n"
" el + sum + f1()\n"
" }. \n"
" sum\n"
"}"
"f1 = function()::int {\n"
" x = 0:: int. "
" x\n"
"}"
);
man->runWithoutCompilation();
}

Event Timeline