15 #ifndef Om_Language_Operation_InjectOperation_
21 #ifndef Om_Macro_Precompilation_
23 #include "boost/test/unit_test.hpp"
33 BOOST_AUTO_TEST_SUITE(InjectOperationTest)
35 BOOST_AUTO_TEST_CASE(DefinitionTest) {
42 BOOST_AUTO_TEST_CASE(GeneralTest) {
53 System::Get().Evaluate(
"inject {quote} {fill {a b{{B}} c}} {A} {C} {D} {E}")
67 System::Get().Evaluate(
"inject {copy} {fill {a b{B} c d}} {A} {C} {D} {E}")
81 System::Get().Evaluate(
"inject {drop} {fill {a b{B} c d}} {A} {C} {D} {E}")
85 BOOST_AUTO_TEST_CASE(EmptyInjectorTest) {
96 System::Get().Evaluate(
"inject {} {fill {a b{B} c}} {A} {C} {D} {E}")
100 BOOST_AUTO_TEST_CASE(EmptyOperationTest) {
103 System::Get().Evaluate(
"inject {quote} {} {A} {C} {D} {E}")
107 BOOST_AUTO_TEST_CASE(FlushWithNoOperandsTest) {
114 BOOST_AUTO_TEST_CASE(FlushWithOneOperandTest) {
121 BOOST_AUTO_TEST_CASE(FlushWithTwoOperandsTest) {
123 "inject{quote}{copy}",
128 BOOST_AUTO_TEST_CASE(FlushWithMoreThanTwoOperandsTest) {
139 System::Get().Evaluate(
"inject {quote} {fill {a b c} {A} {B} }")
143 BOOST_AUTO_TEST_SUITE_END()
155 #ifndef Om_Macro_Precompilation_
157 #include "boost/utility/in_place_factory.hpp"
164 Om::Language::Operation::InjectOperation
168 inline char const * Type_::GetName() {
172 template <
typename TheInjectOperation>
173 inline void Type_::GiveElements(
174 TheInjectOperation & theInjectOperation,
175 Consumer & theConsumer
177 theConsumer.TakeElement(
180 if (theInjectOperation.thisScope) {
181 theConsumer.TakeQuotedElements(theInjectOperation.thisInjector);
183 !theInjectOperation.thisScope->IsEmpty()
185 Expression theExpression;
186 theExpression.Take(theInjectOperation.thisOutput);
187 theInjectOperation.thisScope->GiveElements(theExpression);
188 theConsumer.TakeQuotedElements(theExpression);
195 inline Type_::InjectOperation():
200 template <
typename TheProducer>
201 inline bool Type_::TakeQuotedProducer(
202 Evaluation & theEvaluation,
203 TheProducer & theProducer
205 if (this->thisScope) {
207 this->thisScope->IsEmpty()
209 theProducer.GiveElements(*this->thisScope);
212 Expression
const & theInjector = this->thisInjector;
213 theInjector.GiveElements(*this->thisScope);
215 this->thisScope->TakeQuotedProducer(theProducer);
219 this->thisScope->IsEmpty()
221 theEvaluation.TakeQuotedProducer(this->thisOutput);
225 this->thisScope = boost::in_place(
226 boost::ref(this->thisOutput),
228 theEvaluation.GetTranslator()
231 this->thisInjector.TakeElements(theProducer);
236 template <
typename TheOperand>
237 inline bool Type_::TakeOperand(
238 Evaluation & theEvaluation,
239 TheOperand & theOperand
242 !theOperand.IsEmpty()
244 return this->TakeQuotedProducer(
246 *theOperand.GetProgram()
#define Om_Language_Operation_InjectOperation_GetName_()