Mercurial > hg > Gears > Gears
view src/parallel_execution/perlTests/Interface.t @ 696:69a00f5ff08c
green status
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 21 Aug 2020 17:40:35 +0900 |
parents | 9a6d413f1112 |
children | 284fa7d7326e |
line wrap: on
line source
#!/usr/bin/env perl use strict; use warnings; use FindBin; use Test::More tests => 3; #subtests use_ok "Gears::Interface"; #use test subtest 'parse' => sub { subtest 'file_checking' => sub { plan tests => 2; eval { Gears::Interface->parse("nonexistent_file.c") }; ok $@; like( $@, qr/invalid filepath/ ); }; subtest 'parsing_stack' => sub { plan tests => 1; my $stack_header = "$FindBin::Bin/../Stack.h"; my $want = { name => 'Stack', file_name => $stack_header, content => [ 'union Data* stack;', 'union Data* data;', 'union Data* data1;', 'enum Code whenEmpty;', 'enum Code clear;', 'enum Code push;', 'enum Code pop;', 'enum Code pop2;', 'enum Code isEmpty;', 'enum Code get;', 'enum Code get2;', 'enum Code next;' ] }; my $have = Gears::Interface->parse($stack_header); is_deeply ($have, $want, "parsing stack.h"); }; }; subtest 'separate_code_and_data_gear_after_parse' => sub { subtest 'Queue' => sub { plan tests => 1; my $queue_header = "$FindBin::Bin/../Queue.h"; my $want = { 'data' => [ 'union Data* queue;', 'union Data* data;' ], 'content' => [ 'enum Code whenEmpty;', 'enum Code clear;', 'union Data* queue;', 'enum Code put;', 'union Data* data;', 'enum Code take;', 'enum Code isEmpty;', 'enum Code next;' ], 'file_name' => $queue_header, 'name' => 'Queue', 'codes' => [ { 'args' => '...', 'name' => 'whenEmpty' }, { 'args' => 'Impl* queue, __code next(...)', 'name' => 'clear' }, { 'name' => 'put', 'args' => 'Impl* queue, union Data* data, __code next(...)' }, { 'args' => 'Impl* queue, __code next(union Data* data, ...)', 'name' => 'take' }, { 'name' => 'isEmpty', 'args' => 'Impl* queue, __code next(...), __code whenEmpty(...)' }, { 'name' => 'next', 'args' => '...' } ], 'hasOutputArgs' => { 'take' => { 'data' => 'Data*' } } }; my $have = Gears::Interface->separate_code_and_data_gear_after_parse($queue_header); is_deeply ($have, $want, "parsing Queue.h") || diag explain $have; }; subtest 'Stack' => sub { plan tests => 1; my $stack_header = "$FindBin::Bin/../Stack.h"; my $want = { 'hasOutputArgs' => { 'get2' => { 'data1' => 'Type*', 'data' => 'Type*' }, 'pop' => { 'data' => 'Type*' }, 'pop2' => { 'data' => 'Type*', 'data1' => 'Type*' }, 'get' => { 'data' => 'Type*' } }, 'codes' => [ { 'name' => 'whenEmpty', 'args' => '...' }, { 'name' => 'clear', 'args' => 'Impl* stack,__code next(...)' }, { 'name' => 'push', 'args' => 'Impl* stack,Type* data, __code next(...)' }, { 'name' => 'pop', 'args' => 'Impl* stack, __code next(Type* data, ...)' }, { 'args' => 'Impl* stack, __code next(Type* data, Type* data1, ...)', 'name' => 'pop2' }, { 'args' => 'Impl* stack, __code next(...), __code whenEmpty(...)', 'name' => 'isEmpty' }, { 'args' => 'Impl* stack, __code next(Type* data, ...)', 'name' => 'get' }, { 'args' => 'Impl* stack, __code next(Type* data, Type* data1, ...)', 'name' => 'get2' }, { 'name' => 'next', 'args' => '...' } ], 'content' => [ 'union Data* stack;', 'union Data* data;', 'union Data* data1;', 'enum Code whenEmpty;', 'enum Code clear;', 'enum Code push;', 'enum Code pop;', 'enum Code pop2;', 'enum Code isEmpty;', 'enum Code get;', 'enum Code get2;', 'enum Code next;' ], 'file_name' => $stack_header, 'data' => [ 'union Data* stack;', 'union Data* data;', 'union Data* data1;' ], 'name' => 'Stack' }; my $have = Gears::Interface->separate_code_and_data_gear_after_parse($stack_header); is_deeply ($have, $want, "parsing Stack.h") || diag explain $have; }; }; done_testing;