Fortran-F90Namelist

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

META.yml
README
script/test-pod-snippets.PL
t/01_basic.t
t/02_integer.t
t/03_float.t
t/04_double.t
t/05_complex.t
t/06_double_complex.t
t/07_logical.t
t/08_NaN.t
t/10_test1a.t
t/11_test1b.t
t/12_test1c.t
t/13_test1d.t
t/14_test1e.t
t/20_test2a.t
t/21_test2b.t
t/30_test3a.t
t/31_test3b.t
t/40_test4a.t

lib/Fortran/F90Namelist.pm  view on Meta::CPAN

# float:
my $numeric_e = qr/(?:[+-]?)(?=\d|\.\d)\d*(?:\.\d*)?(?:[Ee](?:[+-]?\d+))?/;
# double:
my $numeric_d = qr/(?:[+-]?)(?=\d|\.\d)\d*(?:\.\d*)?(?:[Dd](?:[+-]?\d+))?/;
# float with decimal point, but w/o  exponential part:
my $float     = qr/(?:[-+]?(?:\d+\.\d*|\d*\.\d+))/;

## Extend floating-point numeric tpes by one- or two-point
## compactification of real numbers (any mathematicians here?), aka IEEE
## denormalized numbers (for engineers):
my $NaN = qr/NaN/;
my $Inf = qr/(?:[-+]?)Inf/;
my $ieee_denorm = qr/(?:$NaN|$Inf)/;
#$numeric_e = qr/(?:$numeric_e|$ieee_denorm)/;
#$numeric_d = qr/(?:$numeric_d|$ieee_denorm)/;
$numeric   = qr/(?:$numeric|$ieee_denorm)/;
$float     = qr/(?:$float|$ieee_denorm)/;

## Regexps for the different data type values. Make sure all brackets are
## marked grouping-but-non-capturing (?:...), or else the parsing
## algorithm will fail.
my @regexp;
$regexp[SQ_STRING] = qr/'(?:[^']|'')*'/; # even covers 'toto''s quote'

t/08_NaN.t  view on Meta::CPAN

#!/usr/bin/perl -w
# -*-mode:cperl-*-

# Name:   08_NaN.t
# Author: wd (Wolfgang.Dobler@kis.uni-freiburg.de)
# Date:   12-May-2005
# Description:
#   Part of test suite for Namelist module

use strict;
use Test::More tests => 7;
use Fortran::F90Namelist;

# 1.
my $nl = Fortran::F90Namelist->new();
isa_ok($nl, 'Fortran::F90Namelist');

## Scalar logicals
$nl->parse(<<"HERE");
  &nlist1
    x = NaN,
    y = Inf,
    z = -Inf
  /
HERE

my $hashref1 =
  {
   'x' => {
	   'value' => [ 'NaN' ],
	   'stype' => 'unspecified float', 'type' => 5
	  },
   'y' => {
	   'value' => [ 'Inf' ],
	   'stype' => 'unspecified float', 'type' => 5
	  },
   'z' => {
	   'value' => [ '-Inf' ],
	   'stype' => 'unspecified float', 'type' => 5
	  }

t/08_NaN.t  view on Meta::CPAN

is(       $nl->nslots, 3,        "nslots");

# 4.
is_deeply($nl->hash,   $hashref1, "data");


## Integer arrays, multiplier syntax, interspersed comments
$nl->parse("
!test namelist
&nlist_2
xx=3,5.39,NaN ! array
  yy=2.D0,Inf! another array
zz=2*Inf,3*NaN
!The end
/");
my $hashref2 =
  {
   'xx' => {
	    'value' => [ '3', '5.39', 'NaN' ],
	   'stype' => 'unspecified float',      'type' => 5
	   },
   'yy' => {
	    'value' => [ '2.D0', 'Inf' ],
	   'stype' => 'double precision float', 'type' => 7
	   },
   'zz' => {
	    'value' => [ 'Inf', 'Inf', 'NaN', 'NaN', 'NaN' ],
	   'stype' => 'unspecified float',      'type' => 5
	   }
  };

# 5.
is(       $nl->name,   "nlist_2", "name");

# 6.
is(       $nl->nslots, 3,         "nslots");

# 7.
is_deeply($nl->hash,   $hashref2, "data");


# End of file 08_NaN.t



( run in 0.486 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )