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