Mercurial > hg > GearsTemplate
diff src/parallel_execution/test/queue_test.cbc @ 323:131a04a70dd8
Use generate_stub for stack_test
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Mar 2017 16:07:30 +0900 |
parents | |
children | a9863b41f026 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/test/queue_test.cbc Tue Mar 21 16:07:30 2017 +0900 @@ -0,0 +1,52 @@ +#include "../../context.h" +#include <assert.h> + +__code queueTest1(struct Queue* queue) { + queue->queue = (union Data*)createSingleLinkedQueue(context); + Task* task = new Task(); + task->code = C_queueTest1; + queue->data = (union Data*)task; + queue->next = C_assert1; + goto meta(context, queue->queue->Queue.put); +} + +__code assert1(struct Queue* queue) { + SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue; + assert(singleLinkedQueue->top->data->Task.code == C_queueTest1); + assert(singleLinkedQueue->last->data->Task.code == C_queueTest1); + goto meta(context, C_queueTest2); +} + +__code queueTest2(struct Queue* queue) { + Task* task = new Task(); + task->code = C_queueTest2; + queue->data = (union Data*)task; + queue->next = C_assert2; + goto meta(context, queue->queue->Queue.put); +} + +__code assert2(struct Queue* queue) { + SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue; + assert(singleLinkedQueue->top->data->Task.code == C_queueTest1); + assert(singleLinkedQueue->last->data->Task.code == C_queueTest2); + goto meta(context, C_queueTest3); +} + +__code queueTest3(struct Queue* queue) { + queue->next = C_assert3; + goto meta(context, queue->queue->Queue.take); +} + +__code assert3(struct Queue* queue) { + SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue; + assert(singleLinkedQueue->top->data->Task.code == C_queueTest2); + assert(singleLinkedQueue->last->data->Task.code == C_queueTest2); + goto meta(context, C_exit_code); +} + +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); +}