ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
def_spec.h
Go to the documentation of this file.
1 
7 #include "../src/semtrex.h"
8 #include "../src/receptor.h"
9 #include "spec_utils.h"
10 
11 void testDefValidate() {
12  T *symbols = __sem_get_defs(G_sem,SEM_TYPE_SYMBOL,TEST_CONTEXT);
13  T *structures = __sem_get_defs(G_sem,SEM_TYPE_STRUCTURE,TEST_CONTEXT);
14 
15  Symbol bad_symbol = {1,SEM_TYPE_SYMBOL,99};
16  Structure bad_structure = {2,SEM_TYPE_STRUCTURE,22};
17 
18  // commented out because for now they raise errors...
19  // __d_validate_structure(G_sem,bad_structure,"test");
20  // __d_validate_symbol(G_sem,bad_symbol,"test");
21 }
22 
23 void testDefSymbol() {
25  T *d = __r_make_definitions();
26  int ctx = _sem_new_context(G_sem,d);
27  T *defs = __sem_get_defs(G_sem,SEM_TYPE_SYMBOL,ctx);
28 
29  Symbol ss = _d_define_symbol(G_sem,INTEGER,"shoe size",ctx);
30  T *def = _sem_get_def(G_sem,ss);
31 
32  spec_is_equal(_d_get_def_addr(def),1);
33  spec_is_true(is_symbol(ss));
34  spec_is_equal(_t_children(defs),ss.id);
35  spec_is_ptr_equal(_t_child(defs,ss.id),def);
36  spec_is_sem_equal(_t_symbol(_t_child(defs,ss.id)),SYMBOL_DEFINITION);
37  spec_is_sem_equal(_t_symbol(_t_child(_t_child(defs,ss.id),SymbolDefStructureIdx)),SYMBOL_STRUCTURE);
38  spec_is_sem_equal(_t_symbol(_t_child(_t_child(defs,ss.id),DefLabelIdx)),SYMBOL_LABEL);
39  spec_is_str_equal(t2s(defs),"(SYMBOLS (SYMBOL_DEFINITION (SYMBOL_LABEL (ENGLISH_LABEL:shoe size)) (SYMBOL_STRUCTURE:INTEGER)))");
40 
41  ss = _d_define_symbol(G_sem,NULL_STRUCTURE,"street number",ctx); // pre-declared to NULL
42 
43  spec_is_equal(ss.id,2);
44  spec_is_str_equal(t2s(_t_child(defs,ss.id)),"(SYMBOL_DEFINITION (SYMBOL_LABEL (ENGLISH_LABEL:street number)) (SYMBOL_STRUCTURE:NULL_STRUCTURE))");
45  __d_set_symbol_structure(defs,ss,INTEGER);
46  spec_is_str_equal(t2s(_t_child(defs,ss.id)),"(SYMBOL_DEFINITION (SYMBOL_LABEL (ENGLISH_LABEL:street number)) (SYMBOL_STRUCTURE:INTEGER))");
47  spec_is_equal(_d_get_def_addr(_t_child(defs,ss.id)),ss.id);
48 
49  _sem_free_context(G_sem,ctx);
50  _t_free(d);
52 }
53 
56  T *defs = __sem_get_defs(G_sem,SEM_TYPE_STRUCTURE,TEST_CONTEXT);
57 
58  Structure st = _d_define_structure_v(G_sem,"boolean pair",TEST_CONTEXT,2,BOOLEAN,BOOLEAN);
59 
60  spec_is_str_equal(t2s(_sem_get_def(G_sem,st)),"(STRUCTURE_DEFINITION (STRUCTURE_LABEL (ENGLISH_LABEL:boolean pair)) (STRUCTURE_SEQUENCE (STRUCTURE_SYMBOL:BOOLEAN) (STRUCTURE_SYMBOL:BOOLEAN)))");
61 
63 }
64 
67  T *symbols = __sem_get_defs(G_sem,SEM_TYPE_SYMBOL,SYS_CONTEXT);
68 
69  // test a few built-in symbols
70  spec_is_structure_equal(0,__d_get_symbol_structure(symbols,STRUCTURE_DEFINITION),TUPLE_OF_STRUCTURE_LABEL_AND_STRUCTURE_DEF);
71  spec_is_structure_equal(0,__d_get_symbol_structure(symbols,STRUCTURE_SYMBOL),SYMBOL);
72 
73  // test user-defined symbols
74  symbols = __sem_get_defs(G_sem,SEM_TYPE_SYMBOL,TEST_CONTEXT);
75 
76  Symbol s = _d_define_symbol(G_sem,INTEGER,"shoe size",TEST_CONTEXT);
77  spec_is_sem_equal(__d_get_symbol_structure(symbols,s),INTEGER);
79 }
80 
81 void testGetSize() {
83 
84  // test a few built-in symbols and structures
85  spec_is_long_equal(_d_get_structure_size(G_sem,INTEGER,0),sizeof(int));
86  spec_is_long_equal(_d_get_structure_size(G_sem,BIT,0),sizeof(int));
87  spec_is_long_equal(_d_get_structure_size(G_sem,FLOAT,0),sizeof(float));
88  spec_is_long_equal(_d_get_structure_size(G_sem,XADDR,0),sizeof(Xaddr));
89  spec_is_long_equal(_d_get_symbol_size(G_sem,STRUCTURE_SYMBOL,0),sizeof(Symbol));
90  spec_is_long_equal(_d_get_symbol_size(G_sem,ENGLISH_LABEL,"shoe_size"),10);
91 
92  // test user-defined symbols and structures
93  T *symbols = __sem_get_defs(G_sem,SEM_TYPE_SYMBOL,TEST_CONTEXT);
94  T *structures = __sem_get_defs(G_sem,SEM_TYPE_STRUCTURE,TEST_CONTEXT);
95 
96  Symbol lat = _d_define_symbol(G_sem,FLOAT,"latitude",TEST_CONTEXT); // symbols are declared, structures are defined
97  Symbol lon = _d_define_symbol(G_sem,FLOAT,"longitude",TEST_CONTEXT); // here we declare two meaningful ways to use the structure float
98 
99 
100  // Two symbols, lat and lon are assembled into the structure "latlong"
101  Structure latlong = _d_define_structure_v(G_sem,"latlong",TEST_CONTEXT, 2, lat, lon);
102 
103  // House location is a meaningful use of the structure latlong
104  Symbol house_loc = _d_define_symbol(G_sem,latlong,"house location",TEST_CONTEXT);
105 
106  // Here's the surface of the latlong.
107  float ll[] = {2.0,90.3};
108  spec_is_long_equal(_d_get_symbol_size(G_sem,house_loc,ll),sizeof(ll));
109  spec_is_long_equal(_d_get_structure_size(G_sem,latlong,ll),sizeof(ll));
110 
111  //structure sizing when structure is a singleton
112  Structure latstruct = _d_define_structure_v(G_sem,"latstruct",TEST_CONTEXT, 1, lat);
113  float ls[] = {2.0};
114  spec_is_long_equal(_d_get_structure_size(G_sem,latstruct,ll),sizeof(ls));
115 
116  //@todo what about sizing with optional structural elements...
117 
119 
120  // In the diagram on 20140806_102233.jpg, "Label" is the symbol, "Struct" is the structure.
121  // Use t_dump to display textually the resulting tree structure. Use _td for a T in the context of a given receptor.
122 }
123 
126  T *defs = __sem_get_defs(G_sem,SEM_TYPE_PROCESS,TEST_CONTEXT);
127  T *code = _t_new_root(NOOP); // fake code
128  T *signature = __p_make_signature("result",SIGNATURE_SYMBOL,NULL_SYMBOL,
129  "val",SIGNATURE_STRUCTURE,INTEGER,
130  "exponent",SIGNATURE_STRUCTURE,INTEGER,
131  NULL);
132  T *link = _t_build(G_sem,0,PROCESS_LINK,
133  PROCESS_OF_STRUCTURE,INTEGER,PROCESS_TYPE,OPERATOR,
134  NULL_SYMBOL,NULL_SYMBOL
135  );
136  Process p = _d_define_process(G_sem,code,"power","takes the mathematical power of the two params",signature,link,TEST_CONTEXT);
137 
138  spec_is_true(is_process(p));
139  spec_is_true(!is_symbol(p));
140  spec_is_equal(_t_children(defs),p.id);
141  T *s = _t_child(defs,p.id);
142 
143  spec_is_str_equal(t2s(s),"(PROCESS_DEFINITION (PROCESS_NAME (ENGLISH_LABEL:power)) (PROCESS_INTENTION:takes the mathematical power of the two params) (process:NOOP) (PROCESS_SIGNATURE (OUTPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:result)) (SIGNATURE_SYMBOL:NULL_SYMBOL)) (INPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:val)) (SIGNATURE_STRUCTURE:INTEGER)) (INPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:exponent)) (SIGNATURE_STRUCTURE:INTEGER))) (PROCESS_LINK (PROCESS_OF_STRUCTURE:INTEGER) (PROCESS_TYPE (OPERATOR))))");
144 
146 }
149  T *defs = __sem_get_defs(G_sem,SEM_TYPE_PROCESS,TEST_CONTEXT);
150  T *code = _t_new_root(NOOP); // some code with a template
151  T *t = _t_newr(code,SLOT);
152  _t_news(t,GOAL,RESPONSE_HANDLER);
153  t = _t_newr(code,SLOT);
154  _t_news(t,USAGE,REQUEST_TYPE);
155  _t_news(t,SLOT_IS_VALUE_OF,TEST_INT_SYMBOL);
156  T *signature = __p_make_signature("result",SIGNATURE_SYMBOL,NULL_SYMBOL,NULL);
157  Process p = _d_define_process(G_sem,code,"test_template_proc","long desc..",signature,NULL,TEST_CONTEXT);
158  T *def = _sem_get_def(G_sem,p);
159 
160  T *sig = _t_child(def,ProcessDefSignatureIdx);
161  spec_is_str_equal(t2s(_t_child(sig,2)),"(TEMPLATE_SIGNATURE (EXPECTED_SLOT (GOAL:RESPONSE_HANDLER)) (EXPECTED_SLOT (USAGE:REQUEST_TYPE) (SLOT_IS_VALUE_OF:TEST_INT_SYMBOL)))");
162 
164 }
165 
168  Receptor *r = _r_new(G_sem,TEST_RECEPTOR);
169 
170  Symbol SY(r,lat,FLOAT);
171  Symbol SY(r,lon,FLOAT);
172  Structure ST(r,latlong,2,lat,lon);
173  Symbol SY(r,house_loc,latlong);
174 
175  T *stx = _d_build_def_semtrex(r->sem,house_loc,0);
176  char buf[2000];
177  spec_is_str_equal(_dump_semtrex(r->sem,stx,buf),"/house_loc/(lat,lon)");
178  __t_dump(r->sem,stx,0,buf);
179  spec_is_str_equal(buf,"(SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:house_loc) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:lat)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:lon))))");
180 
181  T *t = _t_parse(G_sem,0,"(house_loc (lat:22.2) (lon:43.9))");
182  spec_is_true(_t_match(stx,t));
183  _t_free(t);
184  t = _t_parse(G_sem,0,"(house_loc (lat:22.2) (lat:43.9))");
185  spec_is_false(_t_match(stx,t));
186  _t_free(t);
187  _t_free(stx);
188 
189  stx = _d_build_def_semtrex(r->sem,HTTP_REQUEST,0);
190  spec_is_str_equal(t2s(stx),"(SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_LINE) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_VERSION) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:VERSION_MAJOR)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:VERSION_MINOR)))) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_METHOD)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_PATH) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_PATH_SEGMENTS) (SEMTREX_ZERO_OR_MORE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_PATH_SEGMENT)))) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_PATH_FILE) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:FILE_NAME)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:FILE_EXTENSION)))) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_PATH_QUERY) (SEMTREX_ZERO_OR_MORE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_PATH_QUERY_PARAMS) (SEMTREX_ZERO_OR_MORE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_PATH_QUERY_PARAM) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:PARAM_KEY)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:PARAM_VALUE)))))))))))) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_HEADERS) (SEMTREX_ZERO_OR_MORE (SEMTREX_OR (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_HEADER) (SEMTREX_OR (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_HOST)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_USER_AGENT)))) (SEMTREX_OR (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_GENERAL_HEADER) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HEADER_KEY)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HEADER_VALUE)))) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_ENTITY_HEADER) (SEMTREX_OR (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:CONTENT_TYPE) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:MEDIA_TYPE_IDENT)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:MEDIA_SUBTYPE_IDENT)) (SEMTREX_ZERO_OR_MORE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:MEDIA_PARAM) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:PARAM_KEY)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:PARAM_VALUE))))))) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:CONTENT_ENCODING)))))))) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_BODY) (SEMTREX_ZERO_OR_MORE (SEMTREX_SYMBOL_ANY)))))");
191  spec_is_str_equal(_dump_semtrex(G_sem,stx,buf),"/HTTP_REQUEST/(HTTP_REQUEST_LINE/(HTTP_REQUEST_VERSION/(VERSION_MAJOR,VERSION_MINOR),HTTP_REQUEST_METHOD,HTTP_REQUEST_PATH/(HTTP_REQUEST_PATH_SEGMENTS/HTTP_REQUEST_PATH_SEGMENT*,HTTP_REQUEST_PATH_FILE/(FILE_NAME,FILE_EXTENSION),HTTP_REQUEST_PATH_QUERY/HTTP_REQUEST_PATH_QUERY_PARAMS/HTTP_REQUEST_PATH_QUERY_PARAM/(PARAM_KEY,PARAM_VALUE)**)),HTTP_REQUEST_HEADERS/HTTP_REQUEST_HEADER/(HTTP_REQUEST_HOST|HTTP_REQUEST_USER_AGENT)|(HTTP_GENERAL_HEADER/(HEADER_KEY,HEADER_VALUE)|HTTP_ENTITY_HEADER/(CONTENT_TYPE/(MEDIA_TYPE_IDENT,MEDIA_SUBTYPE_IDENT,MEDIA_PARAM/(PARAM_KEY,PARAM_VALUE)*)|CONTENT_ENCODING))*,HTTP_REQUEST_BODY/.*)");
192 
193  //debug_enable(D_STX_MATCH);
194  spec_is_true(_t_match(stx,G_http_req_example));
195  debug_disable(D_STX_MATCH+D_STX_BUILD);
196 
197  _t_free(stx);
198  _r_free(r);
199 
200  stx = _d_build_def_semtrex(r->sem,ASCII_CHARS,0);
201  spec_is_str_equal(t2s(stx),"(SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:ASCII_CHARS) (SEMTREX_ONE_OR_MORE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:ASCII_CHAR))))");
202  spec_is_str_equal(_dump_semtrex(r->sem,stx,buf),"/ASCII_CHARS/ASCII_CHAR+");
203 
204  _t_free(stx);
205 
207 }
208 
209 void testDefSysDefs() {
210  SemanticID vmhr = {SYS_CONTEXT,SEM_TYPE_RECEPTOR,0};
211  spec_is_sem_equal(vmhr,SYS_RECEPTOR);
212 
213  spec_is_equal(G_sem->contexts,_NUM_DEFAULT_CONTEXTS);
214  spec_is_equal(_t_children(G_sem->stores[0].definitions),6); // should have slots for all the defs
215  spec_is_equal(_t_children(_t_child(G_sem->stores[0].definitions,SEM_TYPE_STRUCTURE)),NUM_SYS_STRUCTURES-1);
216  spec_is_equal(_t_children(_t_child(G_sem->stores[0].definitions,SEM_TYPE_SYMBOL)),NUM_SYS_SYMBOLS-1);
217 
218  dump2json(G_sem,__sem_context(G_sem,SYS_CONTEXT)->definitions,"sysdefs");
219 
220  // an example of a defined structure (STRUCTURE_DEF)
221  spec_is_str_equal(t2s(_sem_get_def(G_sem,STRUCTURE_DEF)),"(STRUCTURE_DEFINITION (STRUCTURE_LABEL (ENGLISH_LABEL:STRUCTURE_DEF)) (STRUCTURE_OR (STRUCTURE_SYMBOL:STRUCTURE_SYMBOL) (STRUCTURE_SYMBOL:STRUCTURE_SEQUENCE) (STRUCTURE_SYMBOL:STRUCTURE_OR) (STRUCTURE_SYMBOL:STRUCTURE_ZERO_OR_MORE) (STRUCTURE_SYMBOL:STRUCTURE_ONE_OR_MORE) (STRUCTURE_SYMBOL:STRUCTURE_ZERO_OR_ONE) (STRUCTURE_SYMBOL:STRUCTURE_STRUCTURE) (STRUCTURE_SYMBOL:STRUCTURE_ANYTHING)))");
222 
223  spec_is_str_equal(t2s(_sem_get_def(G_sem,CSTRING)),"(STRUCTURE_DEFINITION (STRUCTURE_LABEL (ENGLISH_LABEL:CSTRING)) (STRUCTURE_SYMBOL:NULL_SYMBOL))");
224 
225  // an example of a defined process (IF)
226  spec_is_str_equal(t2s(_sem_get_def(G_sem,IF)),"(PROCESS_DEFINITION (PROCESS_NAME (ENGLISH_LABEL:IF)) (PROCESS_INTENTION:if) (process:NULL_PROCESS) (PROCESS_SIGNATURE (OUTPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:result)) (SIGNATURE_PASSTHRU)) (INPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:condition)) (SIGNATURE_PROCESS:BOOLEAN)) (INPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:then)) (SIGNATURE_ANY)) (INPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:else)) (SIGNATURE_ANY) (SIGNATURE_OPTIONAL))))");
227 
228  // an example of a defined linked process (LT_INT)
229  spec_is_str_equal(t2s(_sem_get_def(G_sem,LT_INT)),"(PROCESS_DEFINITION (PROCESS_NAME (ENGLISH_LABEL:LT_INT)) (PROCESS_INTENTION:test less than) (process:NULL_PROCESS) (PROCESS_SIGNATURE (OUTPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:result)) (SIGNATURE_SYMBOL:BOOLEAN)) (INPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:int1)) (SIGNATURE_STRUCTURE:INTEGER)) (INPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:int2)) (SIGNATURE_STRUCTURE:INTEGER))) (PROCESS_LINK (PROCESS_OF_STRUCTURE:INTEGER) (PROCESS_TYPE (OPERATOR))))");
230 
231  // an example of a process with code
232  spec_is_str_equal(t2s(_sem_get_def(G_sem,respond_with_yup)),"(PROCESS_DEFINITION (PROCESS_NAME (ENGLISH_LABEL:respond_with_yup)) (PROCESS_INTENTION:respond with yup) (process:RESPOND (SIGNAL_REF:/2/1/4) (YUP)) (PROCESS_SIGNATURE (OUTPUT_SIGNATURE (SIGNATURE_LABEL (ENGLISH_LABEL:response id)) (SIGNATURE_SYMBOL:SIGNAL_UUID))))");
233 
234  // an example of a defined protocol (alive)
235  spec_is_str_equal(t2s(_sem_get_def(G_sem,ALIVE)),"(PROTOCOL_DEFINITION (PROTOCOL_LABEL (ENGLISH_LABEL:ALIVE)) (PROTOCOL_SEMANTICS (ROLE:SERVER) (ROLE:CLIENT) (GOAL:HANDLER)) (alive (EXPECT (ROLE:SERVER) (SOURCE (ROLE:CLIENT)) (PATTERN (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:PING))) (ACTION:respond_with_yup)) (EXPECT (ROLE:CLIENT) (SOURCE (ROLE:SERVER)) (PATTERN (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:YUP))) (SLOT (GOAL:HANDLER) (SLOT_IS_VALUE_OF:ACTION)))))");
236 
237  // an example of an a extra label:
238  spec_is_str_equal(t2s(_sem_get_def(G_sem,CONTENT_TYPE)),"(SYMBOL_DEFINITION (SYMBOL_LABEL (ENGLISH_LABEL:CONTENT_TYPE) (HTTP_HEADER_LABEL:Content-Type)) (SYMBOL_STRUCTURE:MEDIA_TYPE))");
239 
240 }
241 
242 void testDefReceptor() {
243  T *d = __r_make_definitions();
244  T *defs;
245 
246  SemanticID s = _d_define_receptor(G_sem,"streamscapes",d,TEST_CONTEXT);
247  defs = _sem_get_defs(G_sem,s);
248  spec_is_str_equal(t2s(defs),"(RECEPTORS (RECEPTOR_DEFINITION (RECEPTOR_LABEL (ENGLISH_LABEL:streamscapes)) (DEFINITIONS (STRUCTURES) (SYMBOLS) (PROCESSES) (RECEPTORS) (PROTOCOLS) (SCAPES))))");
249 
250  T *d2 = __sem_get_defs(G_sem,SEM_TYPE_RECEPTOR, _d_get_receptor_context(G_sem,s));
251 
252  spec_is_ptr_equal(d2,_t_child(d,SEM_TYPE_RECEPTOR));
253 
254  Receptor *r = _r_new(G_sem,s);
255  char *n = _sem_get_name(r->sem,s);
256  spec_is_str_equal(n,"streamscapes");
257  _r_free(r);
258  //@todo undefining things??
259 }
260 
261 
262 void testDef() {
263  testDefSysDefs();
264  testDefValidate();
265  testDefSymbol();
268  testGetSize();
269  testDefProcess();
271  testDefSemtrex();
272  testDefReceptor();
273 }
T * _t_new_root(Symbol symbol)
Definition: tree.c:160
char * _sem_get_name(SemTable *sem, SemanticID s)
Definition: semtable.c:85
Definition: ceptr_types.h:114
void testDefStructure()
Definition: def_spec.h:54
Process _d_define_process(SemTable *sem, T *code, char *name, char *intention, T *signature, T *link, Context c)
Definition: def.c:336
void testGetSymbolStructure()
Definition: def_spec.h:65
void testDefSemtrex()
Definition: def_spec.h:166
SemanticID _d_define_receptor(SemTable *sem, char *label, T *definitions, Context c)
Definition: def.c:457
void testDefProcessTemplate()
Definition: def_spec.h:147
void _r_free(Receptor *r)
Definition: receptor.c:186
void testDefSymbol()
Definition: def_spec.h:23
Symbol _t_symbol(T *t)
Definition: tree.c:1228
T * _t_child(T *t, int i)
Definition: tree.c:1251
T * _d_build_def_semtrex(SemTable *sem, Symbol s, T *parent)
Definition: def.c:433
size_t _d_get_symbol_size(SemTable *sem, Symbol s, void *surface)
Definition: def.c:178
int _t_match(T *semtrex, T *t)
Definition: semtrex.c:809
Structure __d_get_symbol_structure(T *symbols, Symbol s)
Definition: def.c:156
Receptor * _r_new(SemTable *sem, SemanticID r)
Creates a new receptor.
Definition: receptor.c:88
size_t _d_get_structure_size(SemTable *sem, Structure s, void *surface)
Definition: def.c:218
Symbol _d_define_symbol(SemTable *sem, Structure s, char *label, Context c)
Definition: def.c:83
void testGetSize()
Definition: def_spec.h:81
SemTable * sem
pointer back to the genotype table for this receptor's vmhost instance
Definition: ceptr_types.h:242
T * _t_parse(SemTable *sem, T *parent, char *s,...)
Definition: tree.c:919
void testDefProcess()
Definition: def_spec.h:124
char * _dump_semtrex(SemTable *sem, T *s, char *buf)
Definition: semtrex.c:1096
int _t_children(T *t)
Definition: tree.c:1205
void _t_free(T *t)
Definition: tree.c:526
Structure _d_define_structure_v(SemTable *sem, char *label, Context c, int num_params,...)
Definition: def.c:124
T * _t_build(SemTable *sem, T *parent,...)
Definition: tree.c:635