changeset 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 366baa247572
children d9887056ae5b 7d664be4efa5
files src/parallel_execution/CMakeLists.txt src/parallel_execution/test/queue_test.cbc src/parallel_execution/test/stack_test.cbc
diffstat 3 files changed, 103 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Tue Mar 21 03:58:31 2017 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Tue Mar 21 16:07:30 2017 +0900
@@ -83,6 +83,6 @@
   TARGET
       stack_test
   SOURCES 
-      test/stack_test.c SingleLinkedStack.cbc
+      test/stack_test.cbc SingleLinkedStack.cbc
 )
 
--- /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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parallel_execution/test/stack_test.cbc	Tue Mar 21 16:07:30 2017 +0900
@@ -0,0 +1,50 @@
+#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);
+}