annotate src/parallel_execution/test/stack_test.c @ 401:408b4aab7610

Supported par goto iterate statement for perl script
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 Aug 2017 21:50:57 +0900
parents c1512f358c37
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
1 #include "../../context.h"
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <assert.h>
215
50d0d1b468aa Fix stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 208
diff changeset
3
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
4 __code stackTest1(struct Context *context,struct Stack* stack) {
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
5 stack->stack = (union Data*)createSingleLinkedStack(context);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
6 Node* node = &ALLOCATE(context, Node)->Node;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
7 node->color = Red;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
8 Gearef(context, Stack)->stack = stack->stack;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
9 Gearef(context, Stack)->data = node;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
10 Gearef(context, Stack)->next = stackTest2;
215
50d0d1b468aa Fix stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 208
diff changeset
11 goto meta(context, stack->stack->Stack.push);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
14 __code stackTest1_stub(struct Context* context) {
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
15 Stack* stack = Gearef(context, Stack);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
16 goto stackTest1(context, stack);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
17 }
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
19 __code stackTest2(struct Context *context,struct Stack* stack) {
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
20 Node* node = &ALLOCATE(context, Node)->Node;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
21 node->color = Black;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
22 Gearef(context, Stack)->stack = stack->stack;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
23 Gearef(context, Stack)->data = node;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
24 Gearef(context, Stack)->next = stackTest3;
215
50d0d1b468aa Fix stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 208
diff changeset
25 goto meta(context, stack->stack->Stack.push);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
28 __code stackTest2_stub(struct Context* context) {
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
29 SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
30 assert(singleLinkedStack->top->data->Node.color == Red);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
31 Stack* stack = Gearef(context, Stack);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
32 goto stackTest2(context, stack);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
35 __code stackTest3(struct Context *context,struct Stack* stack) {
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
36 Gearef(context, Stack)->stack = stack->stack;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
37 Gearef(context, Stack)->next = assert3;
215
50d0d1b468aa Fix stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 208
diff changeset
38 goto meta(context, stack->stack->Stack.pop);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
41 __code stackTest3_stub(struct Context* context) {
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
42 /*
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
43 assert on stack implementation
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
44 */
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
45 SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack;
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
46 assert(singleLinkedStack->top->data->Node.color == Black);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
47 Stack* stack = Gearef(context, Stack);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
48 goto stackTest3(context, stack);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
49 }
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
51 __code assert3(struct Context *context,struct Node* node, struct Stack* stack) {
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
52 /*
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
53 assert in normal level
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
54 */
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
55 assert(node->color == Red);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
56 goto exit_code(0);
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 }
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 int main(int argc, char const* argv[]) {
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
60 goto stackTest1();
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 }
385
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
62 __code assert3_stub(struct Context* context) {
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
63 Node* node = Gearef(context, Node);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
64 Stack* stack = Gearef(context, Stack);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
65 goto assert3(context, node, stack);
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
66 }
c1512f358c37 add getCodeGear to generate_stub.pl
mir3636
parents: 280
diff changeset
67