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