comparison src/parallel_execution/test/queue_test.cbc @ 390:c93216e68d70

Can work queue_test converted by generate_stub
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 31 Jul 2017 22:40:08 +0900
parents a9863b41f026
children 394e38952c80
comparison
equal deleted inserted replaced
389:d9a7620a1106 390:c93216e68d70
3 3
4 __code queueTest1(struct Queue* queue) { 4 __code queueTest1(struct Queue* queue) {
5 queue->queue = (union Data*)createSingleLinkedQueue(context); 5 queue->queue = (union Data*)createSingleLinkedQueue(context);
6 Node* node = new Node(); 6 Node* node = new Node();
7 node->color = Red; 7 node->color = Red;
8 queue->data = (union Data*)node; 8 goto queue->put(node, queueTest2);
9 queue->next = C_assert1;
10 goto meta(context, queue->queue->Queue.put);
11 }
12
13 __code assert1(struct Queue* queue) {
14 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue;
15 assert(singleLinkedQueue->top->data->Node.color == Red);
16 assert(singleLinkedQueue->last->data->Node.color == Red);
17 goto meta(context, C_queueTest2);
18 } 9 }
19 10
20 __code queueTest2(struct Queue* queue) { 11 __code queueTest2(struct Queue* queue) {
21 Node* node = new Node(); 12 Node* node = new Node();
22 node->color = Black; 13 node->color = Black;
23 queue->data = (union Data*)node; 14 goto queue->put(node, queueTest3);
24 queue->next = C_assert2;
25 goto meta(context, queue->queue->Queue.put);
26 } 15 }
27 16
28 __code assert2(struct Queue* queue) { 17 __code queueTest2_stub(struct Context* context) {
29 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue; 18 SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue);
30 assert(singleLinkedQueue->top->data->Node.color == Red); 19 assert(singleLinkedQueue->top->data->Node.color == Red);
31 assert(singleLinkedQueue->last->data->Node.color == Black); 20 assert(singleLinkedQueue->last->data->Node.color == Red);
32 goto meta(context, C_queueTest3); 21 Queue* queue = Gearef(context, Queue);
22 goto queueTest2(context, queue);
33 } 23 }
34 24
35 __code queueTest3(struct Queue* queue) { 25 __code queueTest3(struct Queue* queue) {
36 queue->next = C_assert3; 26 goto queue->take(assert3);
37 goto meta(context, queue->queue->Queue.take); 27 }
28
29 __code queueTest3_stub(struct Context* context) {
30 SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue);
31 assert(singleLinkedQueue->top->data->Node.color == Red);
32 assert(singleLinkedQueue->last->data->Node.color == Black);
33 Queue* queue = Gearef(context, Queue);
34 goto queueTest3(context, queue);
38 } 35 }
39 36
40 __code assert3(struct Queue* queue) { 37 __code assert3(struct Queue* queue) {
41 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue; 38 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue;
42 assert(singleLinkedQueue->top->data->Node.color == Black); 39 assert(singleLinkedQueue->top->data->Node.color == Black);
43 assert(singleLinkedQueue->last->data->Node.color == Black); 40 assert(singleLinkedQueue->last->data->Node.color == Black);
44 goto meta(context, C_exit_code); 41 goto exit_code(context);
45 } 42 }
46 43
47 int main(int argc, char const* argv[]) { 44 int main(int argc, char const* argv[]) {
48 struct Context* main_context = NEW(struct Context); 45 struct Context* main_context = NEW(struct Context);
49 initContext(main_context); 46 initContext(main_context);