/*
 * skipdetection.cpp
 *
 *  Created on: Jul 10, 2015
 *      Author: pgess
 */

#include "passmanager.h"
#include "clasplayer.h"
#include "gtest/gtest.h"

using namespace xreate;
using namespace std;
TEST(SkipDetection, testNoneValueTagExists){
	PassManager* man = PassManager::prepareForCode
			("test = function():: int; entry  {\n"
			"  data = [1..5]::[int].\n"
			"  \n"
			"  result = loop fold(data->i::int, 0->sum::int)::int{\n"
			"    if (i==3)::int {valNull = null. valNull} else {i+sum}\n"
			"  }.\n"
			"  \n"
			"  result\n"
			"}");

	man->runWithoutCompilation();
	ClaspLayer::ModelFragment answer = man->clasp->query(Config::get("clasp.nonevalue"));
	int countNoneValue = 0;
	if (answer)
		countNoneValue = std::distance(answer->first, answer->second);
	EXPECT_EQ(1, countNoneValue);
}
