Fortran.t 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/perl
  2. # ------------------------------------------------------------------------------
  3. # (C) Crown copyright Met Office. All rights reserved.
  4. # For further details please refer to the file COPYRIGHT.txt
  5. # which you should have received as part of this distribution.
  6. # ------------------------------------------------------------------------------
  7. use strict;
  8. use warnings;
  9. use FindBin;
  10. use lib "$FindBin::Bin/../../../lib";
  11. use Test::More (tests => 3);
  12. if (!caller()) {
  13. main(@ARGV);
  14. }
  15. sub main {
  16. my $CLASS = 'Fcm::Build::Fortran';
  17. use_ok($CLASS);
  18. my $util = $CLASS->new();
  19. isa_ok($util, $CLASS);
  20. test_extract_interface($util);
  21. }
  22. sub test_extract_interface {
  23. my ($util) = @_;
  24. my $root = ($0 =~ qr{\A(.+)\.t\z}msx)[0];
  25. my $f90 = $root . '-extract-interface-source.f90';
  26. my $f90_interface = $root . '-extract-interface-result.f90';
  27. open(my($handle_for_source), '<', $f90) || die("$f90: $!");
  28. my @actual_lines = $util->extract_interface($handle_for_source);
  29. close($handle_for_source);
  30. open(my($handle_for_result), '<', $f90_interface)
  31. || die("$f90_interface: $!");
  32. my @expected_lines = readline($handle_for_result);
  33. close($handle_for_result);
  34. is_deeply(\@actual_lines, \@expected_lines, 'extract_interface');
  35. }
  36. __END__