Mercurial > hg > GearsTemplate
view src/parallel_execution/test/stack_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 source
#include "../../context.h" #include <assert.h> __code stackTest1(struct Stack* stack) { stack->stack = (union Data*)createSingleLinkedStack(context); Task* task = new Task(); task->code = C_stackTest1; stack->data = (union Data*)task; stack->next = C_assert1; goto meta(context, stack->stack->Stack.push); } __code assert1(struct Stack* stack) { SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack; assert(singleLinkedStack->top->data->Task.code == C_stackTest1); goto meta(context, C_stackTest2); } __code stackTest2(struct Stack* stack) { Task* task = new Task(); task->code = C_stackTest2; stack->data = (union Data*)task; stack->next = C_assert2; goto meta(context, stack->stack->Stack.push); } __code assert2(struct Stack* stack) { SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack; assert(singleLinkedStack->top->data->Task.code == C_stackTest2); goto meta(context, C_stackTest3); } __code stackTest3(struct Stack* stack) { stack->next = C_assert3; goto meta(context, stack->stack->Stack.pop); } __code assert3(struct Stack* stack) { SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack; assert(singleLinkedStack->top->data->Task.code == C_stackTest1); 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_stackTest1; goto start_code(main_context); }