void
MediaDecoderReaderWrapper::RequestAudioData()
{
  MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
  MOZ_ASSERT(!mShutdown);
  MOZ_ASSERT(mRequestAudioDataCB, "Request audio data without callback!");

  auto p = InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                       &MediaDecoderReader::RequestAudioData);

  if (!mStartTimeRendezvous->HaveStartTime()) {
    p = p->Then(mOwnerThread, __func__, mStartTimeRendezvous.get(),
                &StartTimeRendezvous::ProcessFirstSample<MediaData::AUDIO_DATA>,
                &StartTimeRendezvous::FirstSampleRejected<MediaData::AUDIO_DATA>)
         ->CompletionPromise();
  }

  RefPtr<MediaDecoderReaderWrapper> self = this;
  mAudioDataRequest.Begin(p->Then(mOwnerThread, __func__,
    [self] (MediaData* aAudioSample) {
      MOZ_ASSERT(self->mRequestAudioDataCB);
      self->mAudioDataRequest.Complete();
      self->OnSampleDecoded(self->mRequestAudioDataCB.get(), aAudioSample, TimeStamp());
    },
    [self] (MediaDecoderReader::NotDecodedReason aReason) {
      MOZ_ASSERT(self->mRequestAudioDataCB);
      self->mAudioDataRequest.Complete();
      self->OnNotDecoded(self->mRequestAudioDataCB.get(), aReason);
    }));
}
Esempio n. 2
0
 static Ret translate_one(interpreter_interface* interface, Inputs... rest, LiteralList& args, int offset) {
    uint32_t ptr_t = args.at((uint32_t)offset - 2).geti32();
    uint32_t ptr_u = args.at((uint32_t)offset - 1).geti32();
    size_t length = args.at((uint32_t)offset).geti32();
    static_assert(std::is_same<std::remove_const_t<T>, char>::value && std::is_same<std::remove_const_t<U>, char>::value, "Currently only support array of (const)chars");
    return Then(interface, array_ptr_impl<T>(interface, ptr_t, length), array_ptr_impl<U>(interface, ptr_u, length), length, args, (uint32_t)offset - 3);
 };
Esempio n. 3
0
	constexpr auto Static_If(TrueFunctor trueFunctor)
	{
		auto sIf = internal::static_if_internal<Condition>{};
		sIf.Then(trueFunctor);
		
		return sIf;
	}
Esempio n. 4
0
void posix_words() {
    Primitive( "getwd", &_getwd );
    Colon( "pwd" ); c("getwd"); c("type"); c("cr"); End();

    Primitive( "(getenv)", &_getenv );
    Primitive( "(setenv)", &_setenv );
    Colon( "getenv" ); c("parse-word"); c("(getenv)"); End();
    Colon( "setenv" ); c("parse-word"); c("parse-word"); c("(setenv)"); End();
    Colon( "printenv" );
          c("parse-word"); c("2dup"); c("type");
          Literal((Cell)'='); c("emit");
          c("(getenv)"); If(); c("type"); Then(); c("cr"); End();

    Primitive( "(system)", &_system );
    Primitive( "(exec)",   &_exec );

    /* mmap() protection */
    Constant( "PROT_EXEC",  (Cell)PROT_EXEC );
    Constant( "PROT_READ",  (Cell)PROT_READ );
    Constant( "PROT_WRITE", (Cell)PROT_WRITE );
    Constant( "PROT_NONE",  (Cell)PROT_NONE );

    /* mmap() Flags */
    Constant( "MAP_FIXED",   (Cell)MAP_FIXED );
    Constant( "MAP_SHARED",  (Cell)MAP_SHARED );
    Constant( "MAP_PRIVATE", (Cell)MAP_PRIVATE );

    Primitive( "mmap", &do_mmap );

    Primitive( "getpid", &_getpid );
    Primitive( "getppid", &_getppid );

    /* Signals for kill */
    Constant( "SIGHUP",    (Cell)SIGHUP );
    Constant( "SIGINT",    (Cell)SIGINT );
    Constant( "SIGQUIT",   (Cell)SIGQUIT );
    Constant( "SIGILL",    (Cell)SIGILL );
    Constant( "SIGTRAP",   (Cell)SIGTRAP );
    Constant( "SIGABRT",   (Cell)SIGABRT );
    Constant( "SIGIOT",    (Cell)SIGIOT );
    Constant( "SIGBUS",    (Cell)SIGBUS );
    Constant( "SIGFPE",    (Cell)SIGFPE );
    Constant( "SIGKILL",   (Cell)SIGKILL );
    Constant( "SIGUSR1",   (Cell)SIGUSR1 );
    Constant( "SIGSEGV",   (Cell)SIGSEGV );
    Constant( "SIGUSR2",   (Cell)SIGUSR2 );
    Constant( "SIGPIPE",   (Cell)SIGPIPE );
    Constant( "SIGALRM",   (Cell)SIGALRM );
    Constant( "SIGTERM",   (Cell)SIGTERM );
    // Constant( "SIGSTKFLT", (Cell)SIGSTKFLT );
    // Constant( "SIGCLD",    (Cell)SIGCLD );
    Constant( "SIGCHLD",   (Cell)SIGCHLD );
    Constant( "SIGCONT",   (Cell)SIGCONT );
    Constant( "SIGSTOP",   (Cell)SIGSTOP );
    Constant( "SIGTSTP",   (Cell)SIGTSTP );

    Primitive( "kill", &_kill );
}
Esempio n. 5
0
	virtual void Run()
	{
		Then("a vector and list with same content in the same order are equivalent", []() {
			AssertThat(ut11::Is::Iterable::Not::EquivalentTo(std::vector<int>({1,2,3,4,5,6,7,8}))(std::list<int>({1,2,3,4,5,6,7,8})), ut11::Is::False);
		});

		Then("a vector and list with same content in a different order are equivalent", []() {
			AssertThat(ut11::Is::Iterable::Not::EquivalentTo(std::vector<int>({1,2,3,4,5,6,7,8}))(std::list<int>({7,8,5,1,4,3,2,6})), ut11::Is::False);
		});

		Then("a vector and list with different content are not equivalent", []() {
			AssertThat(ut11::Is::Iterable::Not::EquivalentTo(std::vector<int>({1,2,3,4,5,6,7,8}))(std::list<int>({17,28,35,41})), ut11::Is::True);
		});

		Then("a vector and list with different but overlapping content are not equivalent", []() {
			AssertThat(ut11::Is::Iterable::Not::EquivalentTo(std::vector<int>({1,2,3,4,5,6,7,8}))(std::list<int>({7,8,5,1})), ut11::Is::True);
		});


		Then("a vector and list with different content with same size are not equivalent", []() {
			AssertThat(ut11::Is::Iterable::Not::EquivalentTo(std::vector<int>({1,2,3,4,5,6,7,8}))(std::list<int>({0,1,2,3,4,5,6,7})), ut11::Is::True);
		});

		Then("Is::Iterable::EquivalentTo() is an operand", []() {
			AssertThat(ut11::detail::IsOperand< decltype(ut11::Is::Iterable::EquivalentTo(std::vector<int>())) >::value, ut11::Is::True);
		});

		Then("Is::EqualTo has an error message", []() {
			AssertThat(ut11::Is::Iterable::EquivalentTo(std::vector<int>()).GetErrorMessage(0), ut11::Is::Not::EqualTo(""));
		});
	}
Esempio n. 6
0
	virtual void Run()
	{
		Then("string containing desired string is true", [&]() {
			AssertThat(ut11::Is::String::Containing("Hell")("AvsdaHelloasdagf"), ut11::Is::True);
		});

		Then("string not containing desired string is false", [&]() {
			AssertThat(ut11::Is::String::Containing("World")("AvsdaHelloasdagf"), ut11::Is::False);
		});

		Then("Is::String::Containing is an operand", []() {
			AssertThat(ut11::detail::IsOperand< decltype(ut11::Is::String::Containing("world")) >::value, ut11::Is::True);
		});

		Then("Is::String::Containing has an error message", []() {
			AssertThat(ut11::Is::String::Containing("world").GetErrorMessage("piano"), ut11::Is::Not::EqualTo(""));
		});
	}
Esempio n. 7
0
bool ut11::detail::TestStageImpl::Run(out::Output& output)
{
  if (!m_once.description.empty())
    {
      output.OnInfo(m_once.description);
    return true;
    }

	auto runInsideTryCatch = [&](std::function<void(void)> func) -> bool {

		try
		{
			func();
		}
		catch (const ut11::detail::TestFailedException& ex)
		{
			output.OnError(ex.GetLine(), ex.GetFile(), ex.GetMessage());
			return false;
		}
		catch(const std::exception& ex)
		{
			output.OnError(ex);
			return false;
		}
		catch(...)
		{
			output.OnUnknownError();
			return false;
		}
		return true;
	};

	auto theFinallyFunction = [&]() -> void {
		output.EndTest();

		Finally(output);
	};
	auto theGivenWhenThenFinallyFunctions = [&]() -> void
	{
		output.BeginTest();

		Given(output);
		When(output);
		Then(output);
		theFinallyFunction();
	};

	if (!runInsideTryCatch(theGivenWhenThenFinallyFunctions))
	{
		runInsideTryCatch(theFinallyFunction);

		return false;
	}
	return true;

}
Esempio n. 8
0
	virtual void Run()
	{
		Then("Is::Infinity(0.0f) is False", []() {
			AssertThat(ut11::Is::Infinity(0.0f), ut11::Is::False);
		});

		Then("Is::Infinity(Infinity) is True", []() {
			AssertThat(ut11::Is::Infinity(std::numeric_limits<float>::infinity()), ut11::Is::True);
			AssertThat(ut11::Is::Infinity(-std::numeric_limits<float>::infinity()), ut11::Is::True);
		});

		Then("Is::Infinity is Operand", []() {
			AssertThat(ut11::detail::IsOperand< decltype(ut11::Is::Infinity) >::value, ut11::Is::True);
		});

		Then("Is::Infinity has an error message", []() {
			AssertThat(ut11::Is::Infinity.GetErrorMessage(0.0f), ut11::Is::Not::EqualTo(""));
		});
	}
void
MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
                                            media::TimeUnit aTimeThreshold)
{
  MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
  MOZ_ASSERT(!mShutdown);
  MOZ_ASSERT(mRequestVideoDataCB, "Request video data without callback!");

  // Time the video decode and send this value back to callbacks who accept
  // a TimeStamp as its second parameter.
  TimeStamp videoDecodeStartTime = TimeStamp::Now();

  if (aTimeThreshold.ToMicroseconds() > 0 &&
      mStartTimeRendezvous->HaveStartTime()) {
    aTimeThreshold += StartTime();
  }

  auto p = InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                       &MediaDecoderReader::RequestVideoData,
                       aSkipToNextKeyframe, aTimeThreshold.ToMicroseconds());

  if (!mStartTimeRendezvous->HaveStartTime()) {
    p = p->Then(mOwnerThread, __func__, mStartTimeRendezvous.get(),
                &StartTimeRendezvous::ProcessFirstSample<MediaData::VIDEO_DATA>,
                &StartTimeRendezvous::FirstSampleRejected<MediaData::VIDEO_DATA>)
         ->CompletionPromise();
  }

  RefPtr<MediaDecoderReaderWrapper> self = this;
  mVideoDataRequest.Begin(p->Then(mOwnerThread, __func__,
    [self, videoDecodeStartTime] (MediaData* aVideoSample) {
      MOZ_ASSERT(self->mRequestVideoDataCB);
      self->mVideoDataRequest.Complete();
      self->OnSampleDecoded(self->mRequestVideoDataCB.get(), aVideoSample, videoDecodeStartTime);
    },
    [self] (MediaDecoderReader::NotDecodedReason aReason) {
      MOZ_ASSERT(self->mRequestVideoDataCB);
      self->mVideoDataRequest.Complete();
      self->OnNotDecoded(self->mRequestVideoDataCB.get(), aReason);
    }));
}
Esempio n. 10
0
	virtual void Run()
	{
		Then("an empty string is empty", []() {
			AssertThat(ut11::Is::Not::Empty(""), ut11::Is::False);
			AssertThat(ut11::Is::Not::Empty(std::string("")), ut11::Is::False);
		});
		Then("an empty vector is empty", []() {
			AssertThat(ut11::Is::Not::Empty(std::vector<int>()), ut11::Is::False);
		});

		Then("a string with content is not empty", []() {
			AssertThat(ut11::Is::Not::Empty("String With Content"), ut11::Is::True);
			AssertThat(ut11::Is::Not::Empty(std::string("String With Content")), ut11::Is::True);
		});
		Then("a vector with content is not empty", []() {
			AssertThat(ut11::Is::Not::Empty(std::vector<int>({1,2,3})), ut11::Is::True);
		});

		Then("Is::Empty is an operand", []() {
			AssertThat(ut11::detail::IsOperand< decltype(ut11::Is::Not::Empty) >::value, ut11::Is::True);
		});

		Then("Is::Empty has an error message", []() {
			AssertThat(ut11::Is::Not::Empty.GetErrorMessage(""), ut11::Is::Not::EqualTo(""));
		});
	}
Esempio n. 11
0
	virtual void Run()
	{
		Then("a vector of type int is iterable of int so false", [&]() {
			AssertThat(ut11::Is::Iterable::Not::Of<int>()(std::vector<int>()), ut11::Is::False);
		});

		Then("an int is not iterable of int so true", [&]() {
			AssertThat(ut11::Is::Iterable::Not::Of<int>()(1), ut11::Is::True);
		});

		Then("a vector of type string not is iterable of int so true", [&]() {
			AssertThat(ut11::Is::Iterable::Not::Of<int>()(std::vector<std::string>()), ut11::Is::True);
		});

		Then("a vector of a child is iterable of base class so false", [&]() {
			AssertThat(ut11::Is::Iterable::Not::Of<BaseClass>()(std::vector<ChildClass>()), ut11::Is::False);
		});

		Then("Is::Iterable::Of<T>() is an operand", []() {
			AssertThat(ut11::detail::IsOperand< decltype(ut11::Is::Iterable::Not::Of<int>()) >::value, ut11::Is::True);
		});

		Then("Is::EqualTo has an error message", []() {
			AssertThat(ut11::Is::Iterable::Not::Of<int>().GetErrorMessage(std::vector<int>()), ut11::Is::Not::EqualTo(""));
		});
	}
void
MediaDecoderReaderWrapper::WaitForData(MediaData::Type aType)
{
  MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
  MOZ_ASSERT(WaitCallbackRef(aType));

  auto p = InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                       &MediaDecoderReader::WaitForData, aType);

  RefPtr<MediaDecoderReaderWrapper> self = this;
  WaitRequestRef(aType).Begin(p->Then(mOwnerThread, __func__,
    [self] (MediaData::Type aType) {
      MOZ_ASSERT(self->WaitCallbackRef(aType));
      self->WaitRequestRef(aType).Complete();
      self->WaitCallbackRef(aType)->OnResolved(aType);
    },
    [self, aType] (WaitForDataRejectValue aRejection) {
      MOZ_ASSERT(self->WaitCallbackRef(aType));
      self->WaitRequestRef(aType).Complete();
      self->WaitCallbackRef(aType)->OnRejected(aRejection);
    }));
}
Esempio n. 13
0
/** \brief Load all the initial dictionary words.
 */
void
init_dictionary(int dictsize) {
    init_compiler(dictsize);
    memory_words();

    compile_primitives();
    compile_core_constants();
    core_words();
    core_extension_words();
    compile_dictionary_words();
    controlflow_words();
    more_core_words();

    compile_double();
    string_words();
    exception_words();
    file_words();
    format_words();
    compile_stack_words();

    implementation_words();
    vocabulary_words();
    interpreter_words();

    platform_words();
    /* FIX - NEED TO DO THESE */
//   Primitive( "d<",     &lesser );      /* ( d1 d2 -- f ) */
//   Primitive( "d>",     &lesser );      /* ( d1 d2 -- f ) */

//   Primitive( "u*",      &um_star );   /* ( x y -- x*y ) */
//   Primitive( "du*",     &um_star );   /* ( x y -- x*y ) */
//   Primitive( "du/mod",  &um_star );   /* ( x y -- x*y ) */
//   Primitive( "du<",     &um_star );   /* ( x y -- x*y ) */

//   Primitive( "m+",      &um_star );   /* ( x y -- x*y ) */
//   Primitive( "m-",      &um_star );   /* ( x y -- x*y ) */
//   Primitive( "m*",      &um_star );   /* ( x y -- x*y ) */
//   Primitive( "m*/",     &um_star );   /* ( x y -- x*y ) */
//   Primitive( "m/",      &um_star );   /* ( x y -- x*y ) */
//   Primitive( "m/mod",   &um_star );   /* ( x y -- x*y ) */
    /* FIX - NEED TO DO THESE */

    /* FIX  - these two words are no longer used - why are they here ?? */
//   Primitive( "um*",  &um_star );   /* ( x y -- x*y ) */
//   Colon( "udm*" );  /* ( d.lo d.hi n -- d.lo' d.hi' ) */
//          c("tuck"); c("um*"); c("drop"); c("-rot"); c("um*");
//          c("rot"); c("+"); End();

    Colon( ".version" );
    DotQuote("Portable ANS Forth - [email protected]");
    c("cr");
    End();

    Colon( "rstrace" );
    DotQuote("( R: ");
    c("rp@");
    c("rp0");
    c("@");
    Do();
    c("i");
    c(".");
    c("space");
    c("/cell");
    PlusLoop();
    DotQuote(" )");
    c("cr");
    End();

    Variable( "argument-hook" );
    /* To( Tick("ndrop"), "argument-hook" ); */
    ACF x = find("unnest");
    To( (Cell)x, "argument-hook" );

    Colon( "cold" );
    c(".version");
    c("cold-chain");
    /* included may be replaced with path-included which reads
       FORTH_PATH environment variable to look in selected
       directories */
    c("debug");
    c("@");
    If();
    DotQuote("Loading Forth files...");
    Then();
    /* StringLiteral("base.fth"); c("included"); */
    DotQuote("loading base.fth");
    c("cr");
    StringLiteral("base.fth");
    Tick("included");
    c("catch");
    c("?aborted");
    If();
    DotQuote("Failed to load.");
    c("cr");
    Then();

    c("debug");
    c("@");
    If();
    DotQuote("done.");
    c("cr");
    Then();
    c("hex");
#if 0
    c("argument-hook");
    c("@");
    Tick("execute");
    c("catch");
    c("?aborted");
    If();
    DotQuote("argument-hook failed");
    c("cr");
    Then();
#endif
    c("read-eval-loop");
    End();

    Colon( "warm" );
    DotQuote( "Warm Started." );
    c("cr");
    c("rstrace");
    c("quit");
    End();

    /* header */
    Colon( "name," );
    c("dup");
    c("1+");
    c("talign");
    c("allot");
    c("dup");
    c("here");
    c("1-");
    c("c!");
    c("here");
    c("1-");
    c("over");
    c("-");
    c("swap");
    c("cmove");
    End();

    Colon( "header" );
    c("name,");
    c("link");
    c("do-create");
    c(",");
    End();
    Colon( "create" );
    c("parse-word");
    c("header");
    End();

    Colon( "codefield" );  /* ( codefield -- ) */
    c("lastacf");
    c("!");
    End();

    Colon( ":" );
    c("create");
    c("hide");
    c("do-colon");
    c("codefield");
    c("]");
    End();
    Colon( ";" );
    c("compile");
    c("unnest");
    c("[");
    c("reveal");
    End();
    immediate();
}
Esempio n. 14
0
 static Ret translate_one(interpreter_interface* interface, Inputs... rest, LiteralList& args, int offset) {
    auto& last = args.at(offset);
    auto native = convert_literal_to_native<Input>(last);
    return Then(interface, native, rest..., args, (uint32_t)offset - 1);
 };
Esempio n. 15
0
	virtual void Run()
	{
		Given("an entity component store with added entities and with components", [&]() 
		{
			m_entityComponentStore = ecs::EntityComponentStore<int>();
			m_actualEntities = std::vector<int>();

			m_entities = { 1, 2, 3, 4, 5 };
			for (auto entity : m_entities)
				m_entityComponentStore.addEntity(entity);

			m_entitiesWithStringComponent.push_back(m_entities[2]);
			m_entitiesWithIntComponent.push_back(m_entities[2]);
			m_entitiesWithIntComponent.push_back(m_entities[3]);

			m_expectedStringComponentValue = std::string("test_component1");
			m_expectedIntComponentValue = 7;

			for (auto entity : m_entitiesWithStringComponent)
				m_entityComponentStore.addComponent(entity, m_expectedStringComponentValue);

			for (auto entity : m_entitiesWithIntComponent)
				m_entityComponentStore.addComponent(entity, m_expectedIntComponentValue);
		});
		Then("getting the string component of an entity gives the expected value", [&]()
		{
			std::string component = m_entityComponentStore.getComponentOfEntity<std::string>(m_entitiesWithStringComponent[0]);
			AssertThat(component, ut11::Is::EqualTo(m_expectedStringComponentValue));
		});
		Then("getting the int component of an entity gives the expected value", [&]()
		{
			int component = m_entityComponentStore.getComponentOfEntity<int>(m_entitiesWithIntComponent[0]);
			AssertThat(component, ut11::Is::EqualTo(m_expectedIntComponentValue));
		});
		Then("getting a component of an entity that does not exist throws the expected exception", [&]()
		{
			AssertThat([&]() { m_entityComponentStore.getComponentOfEntity<std::string>(100); }, ut11::Will::Throw<ecs::EntityNotFoundException>());
		});
		Then("getting a component of an entity that does not have that component throws the expected exception", [&]()
		{
			AssertThat([&]() { m_entityComponentStore.getComponentOfEntity<std::string>(m_entities[4]); }, ut11::Will::Throw<ecs::ComponentNotFoundException>());
		});
		When("getting all entities", [&]() 
		{
			m_actualEntities = m_entityComponentStore.getAllEntities();
		});
		Then("the expected entities are returned", [&]() 
		{
			AssertThat(m_actualEntities, ut11::Is::Iterable::EquivalentTo(m_entities));
		});
		When("getting all entities with string components", [&]()
		{
			m_actualEntities = m_entityComponentStore.getAllEntitiesFor<std::string>();
		});
		Then("the expected entities are returned", [&]()
		{
			AssertThat(m_actualEntities, ut11::Is::Iterable::EquivalentTo(m_entitiesWithStringComponent));
		});
		When("getting all entities with int components", [&]()
		{
			m_actualEntities = m_entityComponentStore.getAllEntitiesFor<int>();
		});
		Then("the expected entities are returned", [&]()
		{
			AssertThat(m_actualEntities, ut11::Is::Iterable::EquivalentTo(m_entitiesWithIntComponent));
		});
	}
Esempio n. 16
0
	virtual void Run()
	{
		Given("an output stream and output", [&]()
		{
			m_actualOutput.str("");
			m_output = std::unique_ptr<ut11::out::StdOutput>(new ut11::out::StdOutput(m_actualOutput));
		});
		When("begin and end without running any tests", [&]()
		{
			m_output->Begin();
			m_output->Finish(10, 7);
		});
		Then("the output is as expected", [&]()
		{
			AssertThat(m_actualOutput.str(), ut11::Is::EqualTo("\nFinished!\nRan: 10\nSucceeded: 7\n"));
		});

		When("running a test fixture with just a Then", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\t\tThen: then \n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running two test fixtures with just a Then", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->BeginFixture("fixture2");
			m_output->BeginTest();
			m_output->BeginThen("then2");
			m_output->EndThen("then2");
			m_output->EndTest();
			m_output->EndFixture("fixture2");
			m_output->Finish(2, 2);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			startOfTime = stringVal.find('[');
			endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\t\tThen: then \nFixture: fixture2\n\t\t\tThen: then2 \n\nFinished!\nRan: 2\nSucceeded: 2\n"));
		});

		When("running a test fixture with just a When and Then", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\tWhen: when\n\t\t\tThen: then \n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a Given When and Then", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then \n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a Given When Then Finally", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then \n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with multiple tests with a Given When Then Finally where the Given and Whens repeat", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then2");
			m_output->EndThen("then2");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			startOfTime = stringVal.find('[');
			endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then \n\t\t\tThen: then2 \n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a When Then Finally", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\tWhen: when\n\t\t\tThen: then \n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a Then Finally", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginThen("then");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 1);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			auto endOfTime = stringVal.find(']');
			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\t\tThen: then \n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 1\n"));
		});

		When("running a test fixture with a Given When Then Finally and the Then fails with an std::exception", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->OnError(std::runtime_error("error"));
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then\n\tFailed: std::exception was thrown [what(): error]\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});

		When("running a test fixture with a Given When Then Finally and the Then fails with an unknown error", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->OnUnknownError();
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then\n\tFailed: Unknown Error\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});

		When("running a test fixture with a Given When Then Finally and the Then fails", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->EndWhen("then");
			m_output->BeginThen("then");
			m_output->OnError(10, "file", "error");
			m_output->EndThen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\t\t\tThen: then\n\tFailed: [10:file] error\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});


		When("running a test fixture with a Given When Finally and the When fails", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginWhen("when");
			m_output->OnError(10, "file", "error");
			m_output->EndWhen("then");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\t\tWhen: when\n\tFailed: [10:file] error\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});


		When("running a test fixture with a Given Finally and the Given fails", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->OnError(10, "file", "error");
			m_output->EndGiven("given");
			m_output->BeginFinally("finally");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\tFailed: [10:file] error\n\tFinally: finally\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});

		When("running a test fixture with a Given Finally and the Finally fails", [&]()
		{
			m_output->Begin();
			m_output->BeginFixture("fixture");
			m_output->BeginTest();
			m_output->BeginGiven("given");
			m_output->EndGiven("given");
			m_output->BeginFinally("finally");
			m_output->OnError(10, "file", "error");
			m_output->EndFinally("finally");
			m_output->EndTest();
			m_output->EndFixture("fixture");
			m_output->Finish(1, 0);
		});
		Then("the output is as expected", [&]()
		{
			auto stringVal = m_actualOutput.str();
			auto startOfTime = stringVal.find('[');
			startOfTime = stringVal.substr(startOfTime + 1).find('[') + startOfTime;

			auto endOfTime = stringVal.find(']');
			endOfTime = stringVal.substr(endOfTime + 1).find(']') + endOfTime + 1;

			stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);

			AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\tGiven: given\n\tFinally: finally\n\tFailed: [10:file] error\n\nFinished!\nRan: 1\nSucceeded: 0\n"));
		});
	}
Esempio n. 17
0
 static Ret translate_one(interpreter_interface* interface, Inputs... rest, LiteralList& args, int offset) {
    uint32_t ptr = args.at((uint32_t)offset).geti32();
    return Then(interface, null_terminated_ptr_impl(interface, ptr), rest..., args, (uint32_t)offset - 1);
 };
Esempio n. 18
0
 static Ret translate_one(interpreter_interface* interface, LiteralList& args, int offset) {
    uint32_t ptr = args.at((uint32_t)offset - 2).geti32();
    uint32_t value = args.at((uint32_t)offset - 1).geti32();
    size_t length = args.at((uint32_t)offset).geti32();
    return Then(interface, array_ptr_impl<char>(interface, ptr, length), value, length, args, (uint32_t)offset - 3);
 };
Esempio n. 19
0
 static Ret translate_one(interpreter_interface* interface, Inputs... rest, LiteralList& args, int offset) {
    uint32_t wasm_value = args.at((uint32_t)offset).geti32();
    auto value = fc::time_point_sec(wasm_value);
    return Then(interface, value, rest..., args, (uint32_t)offset - 1);
 }
Esempio n. 20
0
already_AddRefed<Promise>
Promise::Catch(const Optional<OwningNonNull<AnyCallback> >& aRejectCallback)
{
  Optional<OwningNonNull<AnyCallback> > resolveCb;
  return Then(resolveCb, aRejectCallback);
}
Esempio n. 21
0
	virtual void Run(){

		Given("a MockReturnHandler", [&]() {

			m_returner = ut11::detail::MockReturnHandler<int, char>();
		});

		When("calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = ut11::utility::DefaultValue<int>()();

			m_returnedValue = m_returner.operator ()('A');
		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});

		When("setting the value to be returned and calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = 32;
			m_returner.SetReturn(m_expectedReturnValue);

			m_returnedValue = m_returner.operator ()('A');

		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});


		When("setting the a return function and calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = 32;
			m_expectedArgument = 'Z';

			m_returner.SetReturn([&](char actual)
			{
				m_actualArgument = actual;
				return m_expectedReturnValue;
			});

			m_returnedValue = m_returner.operator ()(m_expectedArgument);

		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});


		Then("the argument passed in to the return function is the expected value", [&]() {

			AssertThat(m_actualArgument, ut11::Is::EqualTo(m_expectedArgument));
		});

		When("setting the a return value, overriding that with a return function and calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = 32;
			m_expectedArgument = 'Z';

			m_returner.SetReturn('A');
			m_returner.SetReturn([&](char actual)
			{
				m_actualArgument = actual;
				return m_expectedReturnValue;
			});

			m_returnedValue = m_returner.operator ()(m_expectedArgument);

		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});


		Then("the argument passed in to the return function is the expected value", [&]() {

			AssertThat(m_actualArgument, ut11::Is::EqualTo(m_expectedArgument));
		});

		When("setting the a return function, overriding that with a return value and calling the MockReturnHandler", [&]() {

			m_expectedReturnValue = 32;

			m_returner.SetReturn([&](char) { return 21; });
			m_returner.SetReturn(m_expectedReturnValue);

			m_returnedValue = m_returner.operator ()(m_expectedArgument);

		});

		Then("the return value is the expected value", [&]() {

			AssertThat(m_returnedValue, ut11::Is::EqualTo(m_expectedReturnValue));
		});
	}