Om
dequote_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_DequoteOperation_
16 
18 
19  #ifdef Om_Macro_Test_
20 
21  #include "om/language/system.hpp"
22 
23  #ifndef Om_Macro_Precompilation_
24 
25  #include "boost/test/unit_test.hpp"
26 
27  #endif
28 
29 namespace Om {
30 
31  namespace Language {
32 
33  namespace Operation {
34 
35  BOOST_AUTO_TEST_SUITE(DequoteOperationTest)
36 
37  BOOST_AUTO_TEST_CASE(DefinitionTest) {
38  BOOST_CHECK_EQUAL(
39  "{dequote}",
40  System::Get().Evaluate("drop find {dequote} system")
41  );
42  }
43 
44  BOOST_AUTO_TEST_CASE(SimpleTest) {
45  BOOST_CHECK_EQUAL(
46  (
47  "1{2}\n"
48  "3"
49  ),
50  System::Get().Evaluate("dequote {1{2}3}")
51  );
52  }
53 
54  BOOST_AUTO_TEST_CASE(SimpleDequoteThenEvaluateTest) {
55  BOOST_CHECK_EQUAL(
56  (
57  "A{b}\n"
58  "c"
59  ),
60  System::Get().Evaluate("define {a {A}} {dequote {a{b}c}}")
61  );
62  }
63 
64  BOOST_AUTO_TEST_SUITE_END()
65 
66  }
67 
68  }
69 
70 }
71 
72  #endif
73 
74 #else
75 
76 // MARK: - Om::Language::Operation::DequoteOperation
77 
78  #define Type_ \
79  Om::Language::Operation::DequoteOperation
80 
81 // MARK: public (static)
82 
83 inline char const * Type_::GetName() {
85 }
86 
87 template <typename TheDequoteOperation>
88 inline void Type_::GiveElements(
89  TheDequoteOperation &,
90  Consumer & theConsumer
91 ) {
92  theConsumer.TakeElement(
93  GetOperator()
94  );
95 }
96 
97 // MARK: public (non-static)
98 
99 template <typename TheOperand>
100 inline bool Type_::TakeOperand(
101  Evaluation & theEvaluation,
102  TheOperand & theOperand
103 ) {
104  assert(
105  !theOperand.IsEmpty()
106  );
107  return this->TakeQuotedProducer(
108  theEvaluation,
109  *theOperand.GetProgram()
110  );
111 }
112 
113 template <typename TheProducer>
114 inline bool Type_::TakeQuotedProducer(
115  Evaluation & theEvaluation,
116  TheProducer & theProducer
117 ) {
118  theEvaluation.TakeProducer(theProducer);
119  return true;
120 }
121 
122  #undef Type_
123 
124 #endif
static System & Get()
Om header file.
#define Om_Language_Operation_DequoteOperation_GetName_()
The Om library.
Definition: code_point.hpp:26
Om header file.