Sha256: 78b196b88443bb2277f6c1a14d335325657c02956ed280cd876dd9069eb44b95

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

#include "catch.hpp"

#include <story.h>
#include <globals.h>
#include <runner.h>
#include <compiler.h>

using namespace ink::runtime;

SCENARIO("A story with external functions and glue", "[external]")
{
	GIVEN("The story")
	{
		auto ink = story::from_file(INK_TEST_RESOURCE_DIR "LookaheadSafe.bin");

		int  cnt = 0;
		auto foo = [&cnt]() {
			cnt += 1;
		};
		WHEN("the function in lookahead save")
		{
			auto thread = ink->new_runner();
			thread->bind("foo", foo, true);
			std::string out = thread->getline();
			REQUIRE(cnt == 3);
			REQUIRE(out == "Call1 glued to Call 2\n");
			out = thread->getline();
			REQUIRE(out == "Call 3 is seperated\n");
			REQUIRE(cnt == 4);
		}
		WHEN("the function is not lookahead save")
		{
			auto thread = ink->new_runner();
			thread->bind("foo", foo, false);
			std::string out = thread->getline();
			REQUIRE(out == "Call1\n");
			REQUIRE(cnt == 1);
			out = thread->getline();
			REQUIRE(out == "glued to Call 2\n");
			REQUIRE(cnt == 2);
			out = thread->getline();
			REQUIRE(out == "Call 3 is seperated\n");
			REQUIRE(cnt == 3);
		}
	}
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
inkcpp_rb-0.1.3 ext/inkcpp_rb/inkcpp/inkcpp_test/LookaheadSafe.cpp
inkcpp_rb-0.1.2 ext/inkcpp_rb/inkcpp/inkcpp_test/LookaheadSafe.cpp
inkcpp_rb-0.1.1 ext/inkcpp_rb/inkcpp/inkcpp_test/LookaheadSafe.cpp
inkcpp_rb-0.1.0 ext/inkcpp_rb/inkcpp/inkcpp_test/LookaheadSafe.cpp