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