PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PNodeTest.cpp File Reference
#include "../base/PNode.h"
#include "../base/Variant.h"
#include "../base/grammar.tab.hpp"
#include <iostream>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 38 of file PNodeTest.cpp.

39{
40 long int a = 12341;
41 long double b = 3352.9933;
42
43
44 cout << "\n\n\n==========================================================\n";
45 cout << "Testing the PNode Class\n";
46 cout << "==========================================================\n";
47
48 /* The PNode test is pretty lame because the class doesn't do much
49 * in and of itself. Probably should use an Evaluator to test it
50 * better.
51 */
52
53 cout << "Constructing Variants" << endl;
54 Variant v1 = 27; //An integer Variant
55 Variant v2 = 343.1234; //A float Variant
56 Variant v3 = Variant("Potato",P_DATA_VARIABLE);//A Variable variant
57
58
59 cout << "\n\n\n---------------------------------------------\n";
60 cout << "Creating new PNodes (All Datanodes)";
61 cout << "\n\n\n---------------------------------------------\n";
62
63 cout << "Creating p0" << endl;
64 PNode * p0 = new DataNode();
65
66
67 cout << "Creating p1" << endl;
68 PNode * p1 = new DataNode(v2);
69
70 cout << "Creating p2" << endl;
71 PNode * p2 = new DataNode(v2);
72
73 cout << "\n\n\n---------------------------------------------\n";
74 cout << "Printing PNodes (All Datanodes)\n";
75 cout << "---------------------------------------------\n";
76
77 cout << *p0 << endl;
78 cout << *p1 << endl;
79 cout << *p2 << endl;
80
81
82
83 cout << "\n\n\n---------------------------------------------\n";
84 cout << "Creating p3" << endl;
85 cout << "---------------------------------------------\n";
86
87 DataNode * p3 = new DataNode(v3);
88
89
90 cout << "Retrieving the variant in P3" << endl;
91 v2 =p3->GetValue();
92 cout << "value: " << flush << v2 << endl;
93
94
95 cout << "---------------------------------------------\n";
96 //-----------------------------------------------
97 cout << "Creating p4" << endl;
98 PNode * p4 = new OpNode(PEBL_ADD, p0, p1);
99
100 cout << "Creating p5" << endl;
101 PNode * p5 = new OpNode(PEBL_SUBTRACT, p2, p3);
102
103 cout << "Creating p6" << endl;
104 PNode * p6 = new OpNode(PEBL_ADD, p4, p5);
105
106
107 cout << "\n\n\n---------------------------------------------\n";
108 cout << "Printing PNodes (Datanodes and Opnodes)\n";
109 cout << "---------------------------------------------\n";
110
111 cout << *p0 << endl;
112 cout << *p1 << endl;
113 cout << *p2 << endl;
114
115
116 cout << *p4 << endl;
117 cout << *p5 << endl;
118 cout << *p6 << endl;
119
120
121
122 cout << "\n\n\n---------------------------------------------\n";
123 cout << "Realigning nodes.\n";
124 cout << "---------------------------------------------\n";
125
126 p0 = ((OpNode*)p6)->GetRight();
127 p1 = ((OpNode*)p5)->GetRight();
128
129 cout << *p0 << endl;
130 cout << *p1 << endl;
131
132 cout << "Finished" << endl;
133 return 0;
134}
const Variant & GetValue() const
Definition PNode.h:152
Definition PNode.h:45

References DataNode::GetValue().