Mercurial > hg > Gears > GearsAgda
annotate src/parallel_execution/test/queue_test.c @ 281:ceb8735aefb0
fix queue_test
author | mir3636 |
---|---|
date | Fri, 03 Feb 2017 18:19:24 +0900 |
parents | 2c2e4e597eb0 |
children |
rev | line source |
---|---|
182 | 1 #include "../context.h" |
2 #include <assert.h> | |
3 | |
209 | 4 __code queueTest1(struct Context* context, struct Task* task, struct Queue* queue) { |
5 task->code = C_queueTest1; | |
6 queue->next = C_queueTest2; | |
182 | 7 queue->data = (union Data*)task; |
203 | 8 goto meta(context, queue->queue->Queue.put); |
182 | 9 } |
10 | |
209 | 11 __code queueTest1_stub(struct Context* context) { |
280 | 12 Queue* queue = createSingleLinkedQueue(context); |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
13 context->data[D_Queue]->Queue.queue = (union Data*)queue; |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
14 SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue; |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
15 assert(singleLinkedQueue->top == NULL); |
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
16 assert(singleLinkedQueue->last == NULL); |
182 | 17 Task* task = &ALLOCATE(context, Task)->Task; |
209 | 18 goto queueTest1(context, |
182 | 19 task, |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
20 &context->data[D_Queue]->Queue); |
182 | 21 } |
22 | |
209 | 23 __code queueTest2(struct Context* context, struct Task* task, struct Queue* queue) { |
24 task->code = C_queueTest2; | |
25 queue->next = C_queueTest3; | |
182 | 26 queue->data = (union Data*)task; |
203 | 27 goto meta(context, queue->queue->Queue.put); |
182 | 28 } |
29 | |
209 | 30 __code queueTest2_stub(struct Context* context) { |
281 | 31 SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue); |
32 assert(singleLinkedQueue->top->data->Task.code == C_queueTest1); | |
216
6578c5c274ba
Not use cast for queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
214
diff
changeset
|
33 assert(singleLinkedQueue->last->data->Task.code == C_queueTest1); |
182 | 34 Task* task = &ALLOCATE(context, Task)->Task; |
209 | 35 goto queueTest2(context, |
182 | 36 task, |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
37 &context->data[D_Queue]->Queue); |
182 | 38 } |
39 | |
209 | 40 __code queueTest3(struct Context* context, struct Queue* queue) { |
41 queue->next = C_queueTest4; | |
203 | 42 goto meta(context, queue->queue->Queue.take); |
182 | 43 } |
44 | |
209 | 45 __code queueTest3_stub(struct Context* context) { |
281 | 46 SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue); |
216
6578c5c274ba
Not use cast for queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
214
diff
changeset
|
47 assert(singleLinkedQueue->top->data->Task.code == C_queueTest1); |
6578c5c274ba
Not use cast for queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
214
diff
changeset
|
48 assert(singleLinkedQueue->last->data->Task.code == C_queueTest2); |
209 | 49 goto queueTest3(context, |
203 | 50 &context->data[D_Queue]->Queue); |
182 | 51 } |
52 | |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
53 __code queueTest4(struct Context* context) { |
213
9e5c504adc21
Add goto exit to queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
212
diff
changeset
|
54 goto meta(context, C_exit_code); |
182 | 55 } |
56 | |
209 | 57 __code queueTest4_stub(struct Context* context) { |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
58 SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue; |
216
6578c5c274ba
Not use cast for queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
214
diff
changeset
|
59 assert(context->data[D_Queue]->Queue.data->Task.code == C_queueTest1); |
6578c5c274ba
Not use cast for queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
214
diff
changeset
|
60 assert(singleLinkedQueue->top->data->Task.code == C_queueTest2); |
6578c5c274ba
Not use cast for queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
214
diff
changeset
|
61 assert(singleLinkedQueue->last->data->Task.code == C_queueTest2); |
212
37d875930061
Fix queue_test error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
209
diff
changeset
|
62 goto queueTest4(context); |
182 | 63 } |
64 | |
65 int main(int argc, char const* argv[]) { | |
257 | 66 struct Context* main_context = NEW(struct Context); |
182 | 67 initContext(main_context); |
209 | 68 main_context->next = C_queueTest1; |
182 | 69 goto start_code(main_context); |
70 } |