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