RoseFE_SourceProcessing

changeset 521:86f180de12be

updated unit tests
author hcm@serenity
date Mon Nov 23 09:26:27 2009 -0600 (2009-11-23)
parents 11408a66c586
children 0ced6d7bf1d8
files PyFort/UnitTests/t_fortFile.py PyFort/UnitTests/t_fortStmts.py
line diff
     1.1 --- a/PyFort/UnitTests/t_fortFile.py	Mon Nov 23 09:26:06 2009 -0600
     1.2 +++ b/PyFort/UnitTests/t_fortFile.py	Mon Nov 23 09:26:27 2009 -0600
     1.3 @@ -24,7 +24,7 @@
     1.4          self.ff.close()
     1.5  
     1.6      def test1(self):
     1.7 -        '''Ffile string method returns the string rep of the file'''
     1.8 +        '''Ffile string method returns the string rep of the file -- KNOWN TO FAIL (fortFile methods need to be updated for new rawline parsing)'''
     1.9  
    1.10          ff = self.ff
    1.11          out = open_t('f1.out.f')
    1.12 @@ -33,7 +33,7 @@
    1.13          out.close()
    1.14  
    1.15      def test2(self):
    1.16 -        '''Ffile readlines method'''
    1.17 +        '''Ffile readlines method -- KNOWN TO FAIL (fortFile methods need to be updated for new rawline parsing)'''
    1.18  
    1.19          ff = self.ff
    1.20          out = open_t('f2.out.f')
    1.21 @@ -42,7 +42,7 @@
    1.22          out.close()
    1.23          
    1.24      def test3(self):
    1.25 -        '''Ffile iterlines method'''
    1.26 +        '''Ffile iterlines method -- KNOWN TO FAIL (fortFile methods need to be updated for new rawline parsing)'''
    1.27  
    1.28          ff = self.ff
    1.29          ll = Ffile.file(self.fname).iterlines()
    1.30 @@ -63,7 +63,7 @@
    1.31          pass
    1.32  
    1.33      def test1(self):
    1.34 -        '''write Ffile to a file'''
    1.35 +        '''write Ffile to a file -- KNOWN TO FAIL (fortFile methods need to be updated for new rawline parsing)'''
    1.36          import os
    1.37  
    1.38          fname = '__tmp.f'
    1.39 @@ -101,7 +101,7 @@
    1.40      f     = file(fname)
    1.41  
    1.42      def test1(self):
    1.43 -        "'here' docs"
    1.44 +        "'here' docs -- KNOWN TO FAIL (fortFile methods need to be updated for new rawline parsing)"
    1.45          ff = heretst.ff
    1.46          f  = heretst.f
    1.47          ae = self.assertEquals
    1.48 @@ -113,7 +113,7 @@
    1.49      fname = fname_t('f2.f')
    1.50  
    1.51      def test1(self):
    1.52 -        'map operation, join short continuation lines'
    1.53 +        'map operation, join short continuation lines -- KNOWN TO FAIL (fortFile methods need to be updated for new rawline parsing)'
    1.54  
    1.55          ae   = self.assertEquals
    1.56          ok   = open_t('f2.f.map_ok.1').read()
    1.57 @@ -124,7 +124,7 @@
    1.58          ae(res,ok)
    1.59  
    1.60      def test2(self):
    1.61 -        'map operation, filter comments'
    1.62 +        'map operation, filter comments -- KNOWN TO FAIL (fortFile methods need to be updated for new rawline parsing)'
    1.63  
    1.64          ae = self.assertEquals
    1.65          ok = open_t('f2.f.map_ok.2').read()
     2.1 --- a/PyFort/UnitTests/t_fortStmts.py	Mon Nov 23 09:26:06 2009 -0600
     2.2 +++ b/PyFort/UnitTests/t_fortStmts.py	Mon Nov 23 09:26:27 2009 -0600
     2.3 @@ -5,7 +5,7 @@
     2.4  
     2.5  from fortExp import LoopControl
     2.6  from fortStmts import *
     2.7 -from fortStmts import _F90ExplLen,_Star,_NoInit,_Kind,_ExplKind,_AssignInit,_PointerInit,_ImplicitDoConstruct
     2.8 +from fortStmts import _F90Len,_F90ExplLen,_Star,_NoInit,_Kind,_ExplKind,_AssignInit,_PointerInit,_ImplicitDoConstruct
     2.9  from useparse  import *
    2.10  
    2.11  class C2(TestCase):
    2.12 @@ -345,11 +345,16 @@
    2.13  
    2.14      def test2(self):
    2.15          '''array slice array constructor assignment (from SCALE)'''
    2.16 -        theString = "e_mid(1:ngrp) = (/( (elnmg(i)+elnmg(i+1))*0.5,i = 1,ngrp )/)"
    2.17 +        theString = "e_mid(1:ngrp) = (/((elnmg(i)+elnmg(i+1))*0.5,i=1,ngrp)/)"
    2.18 +        #theRepr = AssignStmt(App('e_mid',[Ops(':','1','ngrp')]),
    2.19 +        #                     ArrayConstructor([ArrayConstructorImpliedDo(Ops('*',ParenExp(Ops('+',App('elnmg',['i']),
    2.20 +        #                                                                                          App('elnmg',[Ops('+','i','1')]))),'0.5'),
    2.21 +        #                                                                 LoopControl('i','1','ngrp',None))]))
    2.22          theRepr = AssignStmt(App('e_mid',[Ops(':','1','ngrp')]),
    2.23 -                             ArrayConstructor([ArrayConstructorImpliedDo(Ops('*',ParenExp(Ops('+',App('elnmg',['i']),
    2.24 -                                                                                                  App('elnmg',[Ops('+','i','1')]))),'0.5'),
    2.25 -                                                                         LoopControl('i','1','ngrp',None))]))
    2.26 +                             ArrayConstructor([MultiParenExp(
    2.27 +                                 [Ops('*',ParenExp(Ops('+',App('elnmg',['i']),
    2.28 +                                                      App('elnmg',[Ops('+','i','1')]))),'0.5'),
    2.29 +                                 NamedParam('i','1'),'ngrp'])]))
    2.30          self.assertEquals(repr(pps(theString)),repr(theRepr))
    2.31          self.assertEquals(str(pps(theString)),str(theRepr))
    2.32          self.assertEquals(theString,str(pps(theString)))
    2.33 @@ -503,9 +508,17 @@
    2.34  
    2.35          ss = 'character(len=AAA+9),dimension(3) :: gack(*,*)*5,floob,foo*2,bar(2)'
    2.36          v = pps(ss)
    2.37 +        #ae(repr(v).lower(),
    2.38 +        #   repr(CharacterStmt(
    2.39 +        #    [_F90ExplLen(Ops('+','aaa','9'))],
    2.40 +        #    [App('dimension',['3'])],
    2.41 +        #    [_NoInit(Ops('*',App('gack',['*', '*']),'5')),
    2.42 +        #     _NoInit('floob'),
    2.43 +        #     _NoInit(Ops('*','foo','2')),
    2.44 +        #     _NoInit(App('bar',['2']))])).lower())
    2.45          ae(repr(v).lower(),
    2.46             repr(CharacterStmt(
    2.47 -            [_F90ExplLen(Ops('+','aaa','9'))],
    2.48 +            [_F90Len(NamedParam('len',Ops('+','aaa','9')))],
    2.49              [App('dimension',['3'])],
    2.50              [_NoInit(Ops('*',App('gack',['*', '*']),'5')),
    2.51               _NoInit('floob'),
    2.52 @@ -530,7 +543,11 @@
    2.53      def test6(self):
    2.54          '''character type declaration with array constructor (from SCALE: scalelib/free_form_C.f90)'''
    2.55          theString = "character(len=1),dimension(0:27),parameter :: char_array=(/'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',' ',',','r','*','$','&','+','-','z','.','o','p'/)"
    2.56 -        theRepr = CharacterStmt([_F90ExplLen('1')],
    2.57 +        #theRepr = CharacterStmt([_F90ExplLen('1')],
    2.58 +        #                        [App('dimension',[Ops(':','0','27')]), 'parameter'],
    2.59 +        #                        [_AssignInit('char_array',
    2.60 +        #                                     ArrayConstructor(["'0'", "'1'", "'2'", "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "'a'", "'b'", "'c'", "'d'", "'e'", "'f'", "' '", "','", "'r'", "'*'", "'$'", "'&'", "'+'", "'-'", "'z'", "'.'", "'o'", "'p'"]))])
    2.61 +        theRepr = CharacterStmt([_F90Len(NamedParam('len','1'))],
    2.62                                  [App('dimension',[Ops(':','0','27')]), 'parameter'],
    2.63                                  [_AssignInit('char_array',
    2.64                                               ArrayConstructor(["'0'", "'1'", "'2'", "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "'a'", "'b'", "'c'", "'d'", "'e'", "'f'", "' '", "','", "'r'", "'*'", "'$'", "'&'", "'+'", "'-'", "'z'", "'.'", "'o'", "'p'"]))])
    2.65 @@ -541,7 +558,10 @@
    2.66      def test7(self):
    2.67          '''character type declaration with array constructor'''
    2.68          theString = "character(len=1),dimension(2) :: andchars=(/'&','&'/)"
    2.69 -        theRepr = CharacterStmt([_F90ExplLen('1')],
    2.70 +        #theRepr = CharacterStmt([_F90ExplLen('1')],
    2.71 +        #                        [App('dimension',['2'])],
    2.72 +        #                        [_AssignInit('andchars',ArrayConstructor(["'&'","'&'"]))])
    2.73 +        theRepr = CharacterStmt([_F90Len(NamedParam('len','1'))],
    2.74                                  [App('dimension',['2'])],
    2.75                                  [_AssignInit('andchars',ArrayConstructor(["'&'","'&'"]))])
    2.76          self.assertEquals(repr(pps(theString)),repr(theRepr))
    2.77 @@ -759,8 +779,9 @@
    2.78  
    2.79      def test3(self):
    2.80          '''function statement with type real (with modifier)'''
    2.81 -        s = 'real(kind = 16) function foo(x)'
    2.82 -        r = FunctionStmt((RealStmt,[_ExplKind('16')]),'foo',['x'],None)
    2.83 +        s = 'real(kind=16) function foo(x)'
    2.84 +        #r = FunctionStmt((RealStmt,[_ExplKind('16')]),'foo',['x'],None)
    2.85 +        r = FunctionStmt((RealStmt,[_Kind(NamedParam('kind','16'))]),'foo',['x'],None)
    2.86          self.assertEquals(repr(pps(s)),repr(r))
    2.87          self.assertEquals(s,str(r))
    2.88  
    2.89 @@ -773,8 +794,9 @@
    2.90          
    2.91      def test5(self):
    2.92          '''function statement with type real (with modifier) and result specifier'''
    2.93 -        s = 'real(kind = 16) function foo(x) result(y)'
    2.94 -        r = FunctionStmt((RealStmt,[_ExplKind('16')]),'foo',['x'],'y')
    2.95 +        s = 'real(kind=16) function foo(x) result(y)'
    2.96 +        #r = FunctionStmt((RealStmt,[_ExplKind('16')]),'foo',['x'],'y')
    2.97 +        r = FunctionStmt((RealStmt,[_Kind(NamedParam('kind','16'))]),'foo',['x'],'y')
    2.98          self.assertEquals(repr(pps(s)),repr(r))
    2.99          self.assertEquals(s,str(r))
   2.100