-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathtest_type.c
More file actions
65 lines (44 loc) · 1.09 KB
/
test_type.c
File metadata and controls
65 lines (44 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <assert.h>
#include "express/type.h"
/* core */
#include "express/hash.h"
#include "express/linklist.h"
/* non-core */
#include "driver.h"
#include "fff.h"
/*
* mock globals
*/
char * EXPRESSprogram_name;
int yylineno;
int tag_count;
/*
* mock functions
*/
DEFINE_FFF_GLOBALS
FAKE_VALUE_FUNC(int, EXPRESS_fail, Express)
void setup() {
RESET_FAKE(EXPRESS_fail)
TYPEinitialize();
}
int test_type_create_user_defined_tag() {
Schema scope;
Function f;
Type t, g, chk;
Symbol *func_id, *tag_id;
scope = SCHEMAcreate();
func_id = SYMBOLcreate("func1", 1, "test_5");
tag_id = SYMBOLcreate("item1", 1, "test_5");
f = ALGcreate(OBJ_FUNCTION);
f->symbol = *func_id;
DICTdefine(scope->symbol_table, func_id->name, f, func_id, OBJ_FUNCTION);
g = TYPEcreate(generic_);
t = TYPEcreate_nostab(tag_id, f, OBJ_TAG);
chk = TYPEcreate_user_defined_tag(g, f, tag_id);
assert(chk == t);
return 0;
}
struct test_def tests[] = {
{"type_create_user_defined_tag", test_type_create_user_defined_tag},
{NULL}
};