-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzspel_test.frg
128 lines (116 loc) · 2.76 KB
/
zspel_test.frg
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// how to run:
// bop_cmd -u ServiceDesk -f test.frg "run(<test_id>)"
#include "zspel.frg"
void run(int t) {
int i;
for (i = 0; i < argc; i++) {
logf(SIGNIFICANT, "argv[%d]: %s", i, argv[i]);
}
do_test(t);
}
void do_test(int t) {
int i;
// vars are global in loop
// so this is what we have
string str1, str2;
object zobj;
for (i = 0; i < argc; i++) {
logf(SIGNIFICANT, "argv[%d]: %s", i, argv[i]);
}
switch (t) {
// z_binpow
case 0:
printf(z_binpow(-1, -1));
break;
// z_format_to_js_line
case 1:
str1 = "'hello'" + "\n\t" + "\"world\"";
printf(str1);
printf("\n");
printf(z_format_to_js_line(str1));
break;
// z_format_to_json
case 2:
str1 = "param";
str2 = "'hello'" + "\n\t" + "\"world\"";
printf(str1 + ":" + str2);
printf("\n");
printf(z_format_to_json(str1, str2));
break;
// z_format_to_line
case 3:
str1 = "'hello'" + "\n\t" + "\"world\"";
printf(str1);
printf("\n");
printf(z_format_to_line(str1));
break;
// z_get_factory
case 4:
str1 = "z_get_factory:12345";
printf(str1);
printf("\n");
printf(z_get_factory(str1));
break;
// z_get_gl
case 5:
printf(printf((string)z_get_gl()));
printf("\n");
printf(printf((string)z_get_gl(1)));
// z_get_latest_object
case 6:
// z_obj_info
case 7:
printf("valid obj:\n");
zobj = z_get_latest_object("cr", "id > 0 AND active = 1", "MLIST_STATIC");
printf(z_obj_info(zobj) + "\n");
printf("invalid obj:\n");
zobj = z_get_latest_object("cr", "id < 0", "MLIST_STATIC");
printf(z_obj_info(zobj) + "\n");
break;
// z_modulo
case 8:
for (i = 0; i < 5; i++) {
j = i;
if (i & 2) {
j = i * -1;
}
printf("%2d @%2d\n", j, z_modulo(j));
}
break;
// z_obj_by_persid
case 10:
printf("valid obj:\n");
zobj = z_get_latest_object("chgcat", "id > 0 AND delete_flag = 0", "MLIST_STATIC");
printf(z_obj_info(zobj) + "\n");
if (!is_null(zobj)) {
printf("obj by persid:\n");
zobj = z_obj_by_persid(format("%s:%d", zobj.producer_id, zobj.id));
printf(z_obj_info(zobj) + "\n");
}
break;
// z_obj_by_persid
case 11:
printf("valid obj:\n");
zobj = z_get_latest_object("chgcat", "id > 0 AND delete_flag = 0", "MLIST_STATIC");
printf(z_obj_info(zobj) + "\n");
if (!is_null(zobj)) {
printf("obj by persid:\n");
zobj = z_obj_by_persid(format("%s:%d", zobj.producer_id, zobj.id));
printf(z_obj_info(zobj) + "\n");
}
break;
// z_upd_val
case 12:
printf("cr, ref_num 2776300:\n");
z_upd_val("cr", "ref_num = '2776300'", 1, 1,
"summary", (string)now(),
"status", "HOLD",
"UPD_FLAG", "SUPPRESS_TRIGGERS",
"PLAN_B", "CR2ASGN"
);
break;
// who's there?
default:
printf("unknown test\n");
}
}