comparison src/parallel_execution/test/stack_test.cbc @ 442:481fce540daf

Fix goto implement method of generate_stub
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 21 Nov 2017 09:16:12 +0900
parents c93216e68d70
children 831b7f6fd687
comparison
equal deleted inserted replaced
441:5a737c3df91c 442:481fce540daf
1 #include "../../context.h" 1 #include "../../context.h"
2 #include <assert.h> 2 #include <assert.h>
3 3
4 __code stackTest1(struct Stack* stack) { 4 __code stackTest1(struct Stack* stack) {
5 stack->stack = (union Data*)createSingleLinkedStack(context);
6 Node* node = new Node(); 5 Node* node = new Node();
7 node->color = Red; 6 node->color = Red;
8 goto stack->push(node, stackTest2); 7 goto stack->push(node, stackTest2);
8 }
9
10 __code stackTest1_stub(struct Context* context) {
11 Stack* stack = createSingleLinkedStack(context);
12 goto stackTest1(context, stack);
9 } 13 }
10 14
11 __code stackTest2(struct Stack* stack) { 15 __code stackTest2(struct Stack* stack) {
12 Node* node = new Node(); 16 Node* node = new Node();
13 node->color = Black; 17 node->color = Black;
15 } 19 }
16 20
17 __code stackTest2_stub(struct Context* context) { 21 __code stackTest2_stub(struct Context* context) {
18 SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack); 22 SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
19 assert(singleLinkedStack->top->data->Node.color == Red); 23 assert(singleLinkedStack->top->data->Node.color == Red);
20 Stack* stack = Gearef(context, Stack); 24 Stack* stack = (struct Stack*)Gearef(context, Stack)->stack;
21 goto stackTest2(context, stack); 25 goto stackTest2(context, stack);
22 } 26 }
23 27
24 __code stackTest3(struct Stack* stack) { 28 __code stackTest3(struct Stack* stack) {
25 goto stack->pop(assert3); 29 goto stack->pop(assert3);
29 /* 33 /*
30 assert on stack implementation 34 assert on stack implementation
31 */ 35 */
32 SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack); 36 SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
33 assert(singleLinkedStack->top->data->Node.color == Black); 37 assert(singleLinkedStack->top->data->Node.color == Black);
34 Stack* stack = Gearef(context, Stack); 38 Stack* stack = (struct Stack*)Gearef(context, Stack)->stack;
35 goto stackTest3(context, stack); 39 goto stackTest3(context, stack);
36 } 40 }
37 41
38 __code assert3(struct Node* node, struct Stack* stack) { 42 __code assert3(struct Node* node, struct Stack* stack) {
39 /* 43 /*