Mercurial > hg > Gears > GearsAgda
view 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 |
line wrap: on
line source
#include "../context.h" #include <assert.h> __code queueTest1(struct Context* context, struct Task* task, struct Queue* queue) { task->code = C_queueTest1; queue->next = C_queueTest2; queue->data = (union Data*)task; goto meta(context, queue->queue->Queue.put); } __code queueTest1_stub(struct Context* context) { Queue* queue = createSingleLinkedQueue(context); context->data[D_Queue]->Queue.queue = (union Data*)queue; SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue; assert(singleLinkedQueue->top == NULL); assert(singleLinkedQueue->last == NULL); Task* task = &ALLOCATE(context, Task)->Task; goto queueTest1(context, task, &context->data[D_Queue]->Queue); } __code queueTest2(struct Context* context, struct Task* task, struct Queue* queue) { task->code = C_queueTest2; queue->next = C_queueTest3; queue->data = (union Data*)task; goto meta(context, queue->queue->Queue.put); } __code queueTest2_stub(struct Context* context) { SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue); assert(singleLinkedQueue->top->data->Task.code == C_queueTest1); assert(singleLinkedQueue->last->data->Task.code == C_queueTest1); Task* task = &ALLOCATE(context, Task)->Task; goto queueTest2(context, task, &context->data[D_Queue]->Queue); } __code queueTest3(struct Context* context, struct Queue* queue) { queue->next = C_queueTest4; goto meta(context, queue->queue->Queue.take); } __code queueTest3_stub(struct Context* context) { SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue); assert(singleLinkedQueue->top->data->Task.code == C_queueTest1); assert(singleLinkedQueue->last->data->Task.code == C_queueTest2); goto queueTest3(context, &context->data[D_Queue]->Queue); } __code queueTest4(struct Context* context) { goto meta(context, C_exit_code); } __code queueTest4_stub(struct Context* context) { SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue; assert(context->data[D_Queue]->Queue.data->Task.code == C_queueTest1); assert(singleLinkedQueue->top->data->Task.code == C_queueTest2); assert(singleLinkedQueue->last->data->Task.code == C_queueTest2); goto queueTest4(context); } int main(int argc, char const* argv[]) { struct Context* main_context = NEW(struct Context); initContext(main_context); main_context->next = C_queueTest1; goto start_code(main_context); }