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