@matheusbsbs / matheus-bagliano / commits / dde66eb6f1
Fork 0

remote-mediawiki tests: use a more idiomatic dispatch table

Change the dispatch table code in test-gitmw.pl to use a hash where subroutine references are the values. This is more obvious than a hash where the values are strings we'll use to go searching around in the symbol table for the function. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Sep 21, 2020 at 12:39 UTC dde66eb6f1d29c6b5729b41904eaef69234be07c
1 file changed +7 -7
contrib/mw-to-git/t/test-gitmw.pl
+7 -7
@@ -214,12 +214,12 @@ my $fct_to_call = shift;
214
215 wiki_login($wiki_admin, $wiki_admin_pass);
216
217 -my %functions_to_call = qw(
218 - upload_file wiki_upload_file
219 - get_page wiki_getpage
220 - delete_page wiki_delete_page
221 - edit_page wiki_editpage
222 - getallpagename wiki_getallpagename
217 +my %functions_to_call = (
218 + upload_file => \&wiki_upload_file,
219 + get_page => \&wiki_getpage,
220 + delete_page => \&wiki_delete_page,
221 + edit_page => \&wiki_editpage,
222 + getallpagename => \&wiki_getallpagename,
223 );
224 die "$0 ERROR: wrong argument" unless exists $functions_to_call{$fct_to_call};
225 -&{$functions_to_call{$fct_to_call}}(@ARGV);
225 +$functions_to_call{$fct_to_call}->(@ARGV);