annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "../../context.h"
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <assert.h>
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 __code stackTest1(struct Stack* stack) {
350
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
5 Node* node = new Node();
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
6 node->color = Red;
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
7 goto stack->push(node, stackTest2);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
442
481fce540daf Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
10 __code stackTest1_stub(struct Context* context) {
481fce540daf Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
11 Stack* stack = createSingleLinkedStack(context);
481fce540daf Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
12 goto stackTest1(context, stack);
481fce540daf Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
13 }
481fce540daf Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
14
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 __code stackTest2(struct Stack* stack) {
350
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
16 Node* node = new Node();
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
17 node->color = Black;
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
18 goto stack->push(node, stackTest3);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
21 __code stackTest2_stub(struct Context* context) {
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 351
diff changeset
22 SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
23 assert(singleLinkedStack->top->data->Node.color == Red);
442
481fce540daf Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
24 Stack* stack = (struct Stack*)Gearef(context, Stack)->stack;
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
25 goto stackTest2(context, stack);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 __code stackTest3(struct Stack* stack) {
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
29 goto stack->pop(assert3);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
32 __code stackTest3_stub(struct Context* context) {
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
33 /*
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
34 assert on stack implementation
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
35 */
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 351
diff changeset
36 SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
37 assert(singleLinkedStack->top->data->Node.color == Black);
442
481fce540daf Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
38 Stack* stack = (struct Stack*)Gearef(context, Stack)->stack;
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
39 goto stackTest3(context, stack);
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
40 }
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
41
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
42 __code assert3(struct Node* node, struct Stack* stack) {
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
43 /*
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
44 assert in normal level
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
45 */
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
46 assert(node->color == Red);
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
47 goto exit_code(0);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 int main(int argc, char const* argv[]) {
351
3529c7e93c4f fix generate_stub
mir3636
parents: 350
diff changeset
51 goto stackTest1();
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 }