15 #ifndef Om_Language_Operation_ChooseOperation_
23 #ifndef Om_Macro_Precompilation_
25 #include "boost/test/unit_test.hpp"
35 BOOST_AUTO_TEST_SUITE(ChooseOperationTest)
37 BOOST_AUTO_TEST_CASE(DefinitionTest) {
44 BOOST_AUTO_TEST_CASE(GeneralTest) {
47 System::Get().Evaluate(
"choose{empty}{non-empty}{}")
52 System::Get().Evaluate(
"choose{empty}{non-empty}{some operators}")
56 BOOST_AUTO_TEST_SUITE_END()
73 Om::Language::Operation::ChooseOperation
77 inline char const * Type_::GetName() {
81 template <
typename TheChooseOperation>
82 inline void Type_::GiveElements(
83 TheChooseOperation & theChooseOperation,
84 Consumer & theConsumer
86 theConsumer.TakeElement(
89 if (0 < theChooseOperation.thisOperandCount) {
90 theConsumer.TakeElement(theChooseOperation.thisEmptyCase);
91 if (1 < theChooseOperation.thisOperandCount) {
92 theConsumer.TakeElement(theChooseOperation.thisNonEmptyCase);
99 inline Type_::ChooseOperation():
102 thisOperandCount() {}
104 template <
typename TheProducer>
105 inline bool Type_::TakeQuotedProducer(
106 Evaluation & theEvaluation,
107 TheProducer & theProducer
110 theProducer.GiveProgram()
112 return this->TakeOperand(
118 template <
typename TheOperand>
119 inline bool Type_::TakeOperand(
120 Evaluation & theEvaluation,
121 TheOperand & theOperand
124 !theOperand.IsEmpty()
126 assert(this->thisOperandCount < 3);
127 switch (this->thisOperandCount++) {
129 this->thisEmptyCase.Take(theOperand);
132 this->thisNonEmptyCase.Take(theOperand);
136 TheOperand
const & theConstOperand = theOperand;
137 theEvaluation.TakeOperand(
138 theConstOperand.GetProgram()->IsEmpty() ?
139 this->thisEmptyCase :
140 this->thisNonEmptyCase
#define Om_Language_Operation_ChooseOperation_GetName_()