comparison test/call_suite/main.c @ 436:23b12c7ad462

- call_suite cleanup (no change in functionality): removal of unused decl, freeing memory at end, func renaming for clarity, static for tu-local symbols, ...
author Tassilo Philipp
date Wed, 26 Jan 2022 11:37:57 +0100
parents 2b708397bba1
children 135c7fb49c2f
comparison
equal deleted inserted replaced
435:a29baee68340 436:23b12c7ad462
4 Library: test 4 Library: test
5 File: test/call_suite/main.c 5 File: test/call_suite/main.c
6 Description: 6 Description:
7 License: 7 License:
8 8
9 Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, 9 Copyright (c) 2011-2022 Daniel Adler <dadler@uni-goettingen.de>,
10 Tassilo Philipp <tphilipp@potion-studios.com> 10 Tassilo Philipp <tphilipp@potion-studios.com>
11 11
12 Permission to use, copy, modify, and distribute this software for any 12 Permission to use, copy, modify, and distribute this software for any
13 purpose with or without fee is hereby granted, provided that the above 13 purpose with or without fee is hereby granted, provided that the above
14 copyright notice and this permission notice appear in all copies. 14 copyright notice and this permission notice appear in all copies.
31 31
32 32
33 void* G_callvm; 33 void* G_callvm;
34 34
35 35
36 int invoke(char const* signature, void* t) 36 static int invoke(char const* signature, void* t)
37 { 37 {
38 DCCallVM * p = (DCCallVM*) G_callvm; 38 DCCallVM * p = (DCCallVM*) G_callvm;
39 char const * sig = signature; 39 char const * sig = signature;
40 char rtype; 40 char rtype;
41 char atype; 41 char atype;
80 /* test: */ 80 /* test: */
81 sig = signature+1; 81 sig = signature+1;
82 pos = 1; 82 pos = 1;
83 while ( (atype = *sig++) != '\0') { 83 while ( (atype = *sig++) != '\0') {
84 switch(atype) { 84 switch(atype) {
85 case 'c': s = ( V_c[pos] == K_c[pos] ); if (!s) printf("'c':%d: %d != %d ; ", pos, V_c[pos], K_c[pos]); break; 85 case 'c': s = ( V_c[pos] == K_c[pos] ); if (!s) printf("'c':%d: %d != %d ; ", pos, V_c[pos], K_c[pos]); break;
86 case 's': s = ( V_s[pos] == K_s[pos] ); if (!s) printf("'s':%d: %d != %d ; ", pos, V_s[pos], K_s[pos]); break; 86 case 's': s = ( V_s[pos] == K_s[pos] ); if (!s) printf("'s':%d: %d != %d ; ", pos, V_s[pos], K_s[pos]); break;
87 case 'i': s = ( V_i[pos] == K_i[pos] ); if (!s) printf("'i':%d: %d != %d ; ", pos, V_i[pos], K_i[pos]); break; 87 case 'i': s = ( V_i[pos] == K_i[pos] ); if (!s) printf("'i':%d: %d != %d ; ", pos, V_i[pos], K_i[pos]); break;
88 case 'j': s = ( V_j[pos] == K_j[pos] ); if (!s) printf("'j':%d: %ld != %ld ; ", pos, V_j[pos], K_j[pos]); break; 88 case 'j': s = ( V_j[pos] == K_j[pos] ); if (!s) printf("'j':%d: %ld != %ld ; ", pos, V_j[pos], K_j[pos]); break;
89 case 'l': s = ( V_l[pos] == K_l[pos] ); if (!s) printf("'l':%d: %lld != %lld ; ", pos, V_l[pos], K_l[pos]); break; 89 case 'l': s = ( V_l[pos] == K_l[pos] ); if (!s) printf("'l':%d: %lld != %lld ; ", pos, V_l[pos], K_l[pos]); break;
90 case 'p': s = ( V_p[pos] == K_p[pos] ); if (!s) printf("'p':%d: %lld != %lld ; ", pos, (long long) V_p[pos], (long long) K_p[pos]); break; 90 case 'p': s = ( V_p[pos] == K_p[pos] ); if (!s) printf("'p':%d: %p != %p ; ", pos, V_p[pos], K_p[pos]); break;
91 case 'f': s = ( V_f[pos] == K_f[pos] ); if (!s) printf("'f':%d: %f != %f ; ", pos, V_f[pos], K_f[pos]); break; 91 case 'f': s = ( V_f[pos] == K_f[pos] ); if (!s) printf("'f':%d: %f != %f ; ", pos, V_f[pos], K_f[pos]); break;
92 case 'd': s = ( V_d[pos] == K_d[pos] ); if (!s) printf("'d':%d: %f != %f ; ", pos, V_d[pos], K_d[pos]); break; 92 case 'd': s = ( V_d[pos] == K_d[pos] ); if (!s) printf("'d':%d: %f != %f ; ", pos, V_d[pos], K_d[pos]); break;
93 default: printf("unknown atype '%c' ; ", atype); return 0; 93 default: printf("unknown atype '%c' ; ", atype); return 0;
94 } 94 }
95 if (!s) { 95 if (!s) {
96 printf("arg mismatch at %d ; ", pos); 96 printf("arg mismatch at %d ; ", pos);
97 return 0; 97 return 0;
128 { 128 {
129 int total; 129 int total;
130 130
131 dcTest_initPlatform(); 131 dcTest_initPlatform();
132 132
133 init_K(G_maxargs); 133 init_test_data(G_maxargs);
134 G_callvm = (DCCallVM*) dcNewCallVM(4096); 134 G_callvm = (DCCallVM*) dcNewCallVM(4096);
135 dcReset(G_callvm); 135 dcReset(G_callvm);
136 total = run_all(); 136 total = run_all();
137 dcFree(G_callvm);
138 deinit_test_data(G_maxargs);
139
137 printf("result: call_suite: %d\n", total); 140 printf("result: call_suite: %d\n", total);
138 141
139 dcTest_deInitPlatform(); 142 dcTest_deInitPlatform();
140 143
141 return !total; 144 return !total;