Om
back_pull_code_point_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_BackPullCodePointOperation_
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(BackPullCodePointOperationTest)
36 
37  BOOST_AUTO_TEST_CASE(DefinitionTest) {
38  BOOST_CHECK_EQUAL(
39  "{[code` points]->}",
40  System::Get().Evaluate("drop find {[code` points]->} system")
41  );
42  }
43 
44  BOOST_AUTO_TEST_CASE(GeneralTest) {
45  BOOST_CHECK_EQUAL(
46  "{e}{1`{2`}thre}",
47  System::Get().Evaluate("[code` points]-> {1{2}three}")
48  );
49 
50  BOOST_CHECK_EQUAL(
51  "{` }{}",
52  System::Get().Evaluate("[code` points]-> {` }")
53  );
54 
55  BOOST_CHECK_EQUAL(
56  (
57  "{"
58  "\xCC\x81"
59  "}{a"
60  "\xC3\x98"
61  "}"
62  ),
63  System::Get().Evaluate(
64  "[code` points]-> {a"
65  "\xC7\xBE"
66  "}"
67  )
68  );
69 
70  BOOST_CHECK_EQUAL(
71  "{` }{}",
72  System::Get().Evaluate("[code` points]-> { }")
73  );
74 
75  BOOST_CHECK_EQUAL(
76  "{}{}",
77  System::Get().Evaluate("[code` points]-> {}")
78  );
79 
80  BOOST_CHECK_EQUAL(
81  "[code` points]->",
82  System::Get().Evaluate("[code` points]->")
83  );
84  }
85 
86  BOOST_AUTO_TEST_CASE(MultiCodePointCharacterTest) {
87  BOOST_CHECK_EQUAL(
88  (
89  "{"
90  "\xE1\x85\xA1"
91  "}{"
92  "\xE1\x86\xAB"
93  "\xE1\x84\x80"
94  "}"
95  ),
96  System::Get().Evaluate(
97  "[code` points]->"
98  "{"
99  "\xE1\x86\xAB"
100  "\xE1\x84\x80"
101  "\xE1\x85\xA1"
102  "}"
103  )
104  );
105  }
106 
107  BOOST_AUTO_TEST_SUITE_END()
108 
109  }
110 
111  }
112 
113 }
114 
115  #endif
116 
117 #else
118 
120 
121 // MARK: - Om::Language::Operation::BackPullCodePointOperation
122 
123  #define Type_ \
124  Om::Language::Operation::BackPullCodePointOperation
125 
126 // MARK: public (static)
127 
128 inline char const * Type_::GetName() {
130 }
131 
132 inline void Type_::Give(Evaluation & theEvaluation) {
133  theEvaluation.TakeOperation(
134  std::auto_ptr<IncompleteOperation>(
135  new PullOperation<
136  Operator,
137  BackPullCodePointOperation
138  >
139  )
140  );
141 }
142 
143 template <typename TheConsumer>
144 inline void Type_::Pull(
145  Operator & theOperator,
146  TheConsumer & theConsumer
147 ) {
148  theOperator.BackGiveCodePoint(theConsumer);
149 }
150 
151  #undef Type_
152 
153 #endif
#define Om_Language_Operation_BackPullCodePointOperation_GetName_()
static System & Get()
The Om library.
Definition: code_point.hpp:26
std::auto_ptr< TheGiveable > Give(TheGiveable &)
Calls Move on the object.
Om header file.
Om header file.