Skip to content

Commit

Permalink
Fix error occuring by testing from fortran source instead of json ast
Browse files Browse the repository at this point in the history
  • Loading branch information
uNouss committed Jul 31, 2024
1 parent 7501f51 commit 9cba396
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 10 deletions.
53 changes: 52 additions & 1 deletion src/EsopeImporter-Tests/IASTToFamixVisitorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
'visitor',
'programFile'
],
#category : 'EsopeImporter-Tests-Visitor'
#category : #'EsopeImporter-Tests-Visitor'
}

{ #category : #running }
Expand Down Expand Up @@ -522,6 +522,57 @@ IASTToFamixVisitorTest >> testFamixEsopeSegment [
self assert: attribute declaredType name equals: 'integer'.
]

{ #category : #'tests-esope' }
IASTToFamixVisitorTest >> testFamixEsopeSegmentWithPointeur [

"
segment myseg
integer a1(n)
c@_ pointeur a2(n).aseg
end segment
"

| segment entity attribute |

self skip: #TODO. "not yet implement".

segment := self defaultSegment: 'myseg' with: {
(#a1 -> #integer).
(#status -> #logical).
(#age -> #integer) }.

programFile body: { IASTSubroutine new
entityName: 'sub';
body: { segment };
yourself }.

entity := programFile accept: visitor.

self assert: entity programUnits size equals: 1.

self assert: (visitor model allWithType: FamixEsopeSegment) size equals: 1.
entity := (visitor model allWithType: FamixEsopeSegment) first.
self assert: entity name equals: 'myseg'.
self assert: entity isType.
self assert: entity attributes size equals: 3.

self assert: entity attributes size equals: 3.
attribute := entity attributes first.
self assert: attribute class equals: FamixFortranAttribute.
self assert: attribute name equals: 'uname'.
self assert: attribute declaredType name equals: 'character'.

attribute := entity attributes second.
self assert: attribute class equals: FamixFortranAttribute.
self assert: attribute name equals: 'status'.
self assert: attribute declaredType name equals: 'logical'.

attribute := entity attributes third.
self assert: attribute class equals: FamixFortranAttribute.
self assert: attribute name equals: 'age'.
self assert: attribute declaredType name equals: 'integer'.
]

{ #category : #'tests-esope' }
IASTToFamixVisitorTest >> testFamixEsopeSlashWithLitteralDim [

Expand Down
24 changes: 15 additions & 9 deletions src/EsopeImporter-Tests/JsonToIASTVisitorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1450,13 +1450,16 @@ c@_ end segment
{ #category : #'tests-esope' }
JsonToIASTVisitorTest >> testSegmentDeclarationWithArrayAttribute [

| programFile seg |
programFile := self visitF77Code: ' subroutine hello
"
subroutine hello
c@_ segment, foo
integer bar(n)
c@_ end segment
end
'.
"

| programFile seg |
programFile := self visitJsonCode: '{"meta":{"miVersion":"fortran77","miFilename":"<stdin>"},"program_units":[{"anno":[],"arguments":null,"blocks":[{"anno":[],"comment":"@_ segment, foo","span":"(2:1)-(2:18)","tag":"comment"},{"anno":[],"label":null,"span":"(3:9)-(3:22)","statement":{"anno":[],"attributes":null,"declarators":{"anno":[],"list":[{"anno":[],"dims":{"anno":[],"list":[{"anno":[],"lower":null,"span":"(3:21)-(3:21)","upper":{"anno":[],"span":"(3:21)-(3:21)","tag":"value","value":{"contents":"n","tag":"variable"}}}],"span":"(3:21)-(3:21)"},"initial":null,"length":null,"span":"(3:17)-(3:22)","type":"array","variable":{"anno":[],"span":"(3:17)-(3:19)","tag":"value","value":{"contents":"bar","tag":"variable"}}}],"span":"(3:17)-(3:22)"},"span":"(3:9)-(3:22)","tag":"declaration","type":{"anno":[],"base_type":"integer","selector":null,"span":"(3:9)-(3:15)"}},"tag":"statement"},{"anno":[],"comment":"@_ end segment","span":"(4:1)-(4:17)","tag":"comment"}],"name":"hello","options":[null,null],"span":"(1:7)-(5:9)","subprograms":null,"tag":"subroutine"}]}'.

self assert: programFile body first body size equals: 1.
seg := programFile body first body first.
Expand All @@ -1476,13 +1479,14 @@ c@_ end segment
{ #category : #'tests-esope' }
JsonToIASTVisitorTest >> testSegmentDeclarationWithArrayAttributes [

| programFile seg |
programFile := self visitF77Code: ' subroutine hello
" subroutine hello
c@_ segment, foo
integer bar(n, m)
c@_ end segment
end
'.
"
| programFile seg |
programFile := self visitJsonCode: '{"meta":{"miVersion":"fortran77","miFilename":"<stdin>"},"program_units":[{"anno":[],"arguments":null,"blocks":[{"anno":[],"comment":"@_ segment, foo","span":"(2:1)-(2:18)","tag":"comment"},{"anno":[],"label":null,"span":"(3:9)-(3:25)","statement":{"anno":[],"attributes":null,"declarators":{"anno":[],"list":[{"anno":[],"dims":{"anno":[],"list":[{"anno":[],"lower":null,"span":"(3:21)-(3:21)","upper":{"anno":[],"span":"(3:21)-(3:21)","tag":"value","value":{"contents":"n","tag":"variable"}}},{"anno":[],"lower":null,"span":"(3:24)-(3:24)","upper":{"anno":[],"span":"(3:24)-(3:24)","tag":"value","value":{"contents":"m","tag":"variable"}}}],"span":"(3:21)-(3:24)"},"initial":null,"length":null,"span":"(3:17)-(3:25)","type":"array","variable":{"anno":[],"span":"(3:17)-(3:19)","tag":"value","value":{"contents":"bar","tag":"variable"}}}],"span":"(3:17)-(3:25)"},"span":"(3:9)-(3:25)","tag":"declaration","type":{"anno":[],"base_type":"integer","selector":null,"span":"(3:9)-(3:15)"}},"tag":"statement"},{"anno":[],"comment":"@_ end segment","span":"(4:1)-(4:17)","tag":"comment"}],"name":"hello","options":[null,null],"span":"(1:7)-(5:9)","subprograms":null,"tag":"subroutine"}]}'.

self assert: programFile body first body size equals: 1.
seg := programFile body first body first.
Expand All @@ -1503,13 +1507,15 @@ c@_ end segment
{ #category : #'tests-esope' }
JsonToIASTVisitorTest >> testSegmentDeclarationWithArrayPointeurAttribute [

| programFile seg |
programFile := self visitF77Code: ' subroutine hello
"
subroutine hello
c@_ segment, foo
c@_ pointeur bar(n, m).titi
c@_ end segment
end
'.
"
| programFile seg |
programFile := self visitJsonCode: '{"meta":{"miVersion":"fortran77","miFilename":"<stdin>"},"program_units":[{"anno":[],"arguments":null,"blocks":[{"anno":[],"comment":"@_ segment, foo","span":"(2:1)-(2:18)","tag":"comment"},{"anno":[],"comment":"@_ pointeur bar(n, m).titi","span":"(3:1)-(3:31)","tag":"comment"},{"anno":[],"comment":"@_ end segment","span":"(4:1)-(4:17)","tag":"comment"}],"name":"hello","options":[null,null],"span":"(1:7)-(5:9)","subprograms":null,"tag":"subroutine"}]}'.

self assert: programFile body first body size equals: 1.
seg := programFile body first body first.
Expand Down

0 comments on commit 9cba396

Please sign in to comment.