Om
front_pull_pair_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_FrontPullPairOperation_
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(FrontPullPairOperationTest)
34 
35  BOOST_AUTO_TEST_CASE(DefinitionTest) {
36  BOOST_CHECK_EQUAL(
37  "{<-[pairs]}",
38  System::Get().Evaluate("drop find {<-[pairs]} system")
39  );
40  }
41 
42  BOOST_AUTO_TEST_CASE(GeneralTest) {
43  BOOST_CHECK_EQUAL(
44  "{1{2}}{4{5}}",
45  System::Get().Evaluate("<-[pairs] {1{2}4{5}}")
46  );
47 
48  BOOST_CHECK_EQUAL(
49  "{1}{2}",
50  System::Get().Evaluate("<-[pairs] {1 2}")
51  );
52 
53  BOOST_CHECK_EQUAL(
54  "{{2}}{}",
55  System::Get().Evaluate("<-[pairs] {{1}{2}}")
56  );
57 
58  BOOST_CHECK_EQUAL(
59  "{}{}",
60  System::Get().Evaluate("<-[pairs] {}")
61  );
62 
63  BOOST_CHECK_EQUAL(
64  "{only}{}",
65  System::Get().Evaluate("<-[pairs] {only}")
66  );
67 
68  BOOST_CHECK_EQUAL(
69  "{a{b}}{{c}}",
70  System::Get().Evaluate("<-[pairs]{a{b}{c}}")
71  );
72 
73  BOOST_CHECK_EQUAL(
74  "{{c}}{a{b}}",
75  System::Get().Evaluate("<-[pairs]{{c}a{b}}")
76  );
77  }
78 
79  BOOST_AUTO_TEST_CASE(FlushTest) {
80  BOOST_CHECK_EQUAL(
81  "<-[pairs]",
82  System::Get().Evaluate("<-[pairs]")
83  );
84  }
85 
86  BOOST_AUTO_TEST_SUITE_END()
87 
88  }
89 
90  }
91 
92 }
93 
94  #endif
95 
96 #else
97 
98  #include "om/language/lexicon.hpp"
100 
101 // MARK: - Om::Language::Operation::FrontPullPairOperation
102 
103  #define Type_ \
104  Om::Language::Operation::FrontPullPairOperation
105 
106 // MARK: public (static)
107 
108 inline char const * Type_::GetName() {
110 }
111 
112 inline void Type_::Give(Evaluation & theEvaluation) {
113  theEvaluation.TakeOperation(
114  std::auto_ptr<IncompleteOperation>(
115  new PullOperation<
116  Lexicon,
117  FrontPullPairOperation
118  >
119  )
120  );
121 }
122 
123 template <typename TheConsumer>
124 inline void Type_::Pull(
125  Lexicon & theLexicon,
126  TheConsumer & theConsumer
127 ) {
128  theLexicon.FrontGivePair(theConsumer);
129 }
130 
131  #undef Type_
132 
133 #endif
static System & Get()
#define Om_Language_Operation_FrontPullPairOperation_GetName_()
Om header file.
The Om library.
Definition: code_point.hpp:26
std::auto_ptr< TheGiveable > Give(TheGiveable &)
Calls Move on the object.
Om header file.