Skip to content

Commit

Permalink
Merge pull request #159 from moosetechnology/more-tests
Browse files Browse the repository at this point in the history
More tests
  • Loading branch information
NicolasAnquetil authored Jun 30, 2024
2 parents aac925b + cb8fe5f commit 348f596
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/EsopeImporter-Tests/FamixEsopeUtilitiesTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Class {
#superclass : #TestCase,
#instVars : [
'mooseModel',
'famixProgFile'
'programFile'
],
#category : #'EsopeImporter-Tests-Importer'
}
Expand Down Expand Up @@ -51,17 +51,7 @@ FamixEsopeUtilitiesTest >> defaultAttribute: varName withType: typeName [
FamixEsopeUtilitiesTest >> defaultFunction: name [

^ (self newEntity: FamixF77PUFunction named: name) programFile:
famixProgFile
]

{ #category : #'default values' }
FamixEsopeUtilitiesTest >> defaultIASTEsopeCommand: commandName name: entityName [

^ IASTEsopeSegCommand new
esopeCommand: commandName;
entityName: entityName;
sourceAnchor: self defaultAnchor;
yourself
programFile
]

{ #category : #'default values' }
Expand Down Expand Up @@ -102,7 +92,7 @@ FamixEsopeUtilitiesTest >> defaultInvocation: name [
FamixEsopeUtilitiesTest >> defaultMain: name [

^ (self newEntity: FamixF77PUMain named: name) programFile:
famixProgFile
programFile
]

{ #category : #'default values' }
Expand Down Expand Up @@ -141,7 +131,7 @@ FamixEsopeUtilitiesTest >> defaultSegment: segmentName with: dictDeclarations [
FamixEsopeUtilitiesTest >> defaultSubroutine: name [

^ (self newEntity: FamixF77PUSubroutine named: name) programFile:
famixProgFile
programFile
]

{ #category : #'default values' }
Expand Down Expand Up @@ -211,7 +201,7 @@ FamixEsopeUtilitiesTest >> newEntity: aFamixClass named: aName [
FamixEsopeUtilitiesTest >> newPU: aName [

^ (self newEntity: FamixF77PUSubroutine named: aName)
programFile: famixProgFile;
programFile: programFile;
yourself
]

Expand All @@ -221,5 +211,5 @@ FamixEsopeUtilitiesTest >> setUp [
super setUp.

mooseModel := FamixEsopeModel new.
famixProgFile := self defaultProgramFile: './main.f'.
programFile := self defaultProgramFile: './main.f'.
]
38 changes: 38 additions & 0 deletions src/EsopeImporter-Tests/FortranProjectImporterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,44 @@ FortranProjectImporterTest >> testGetIncludedFile [
self assert: names equals: 'blah.inc'
]

{ #category : #'tests - import steps' }
FortranProjectImporterTest >> testIASTToFamix [
"json file and assert: taken from
IASTToFamixVisitorTest >> testFamixFortran77PUFunctionWithParameter"

| iastEntity fmxEntity param |
iastEntity := IASTParameter new
entityName: 'var' ;
yourself.
iastEntity := IASTFunction new
entityName: 'fct' ;
parameters: { iastEntity } ;
yourself.
iastEntity := IASTProgramFile new
filename: './main.f' ;
body: { iastEntity } ;
yourself.
importer iastModel: { iastEntity }.

importer iASTToFamix.

self assert: (importer famixModel allWithType: FamixF77ProgramFile) size equals: 1.

fmxEntity := (importer famixModel allWithType: FamixF77ProgramFile) anyOne.
self assert: fmxEntity programUnits size equals: 1.

fmxEntity := fmxEntity programUnits first.
self assert: fmxEntity class equals: FamixF77PUFunction.
self assert: fmxEntity name equals: 'fct'.
self assert: fmxEntity programFile isNotNil.

self assert: fmxEntity parameters size equals: 1.
param := fmxEntity parameters first.
self assert: param class equals: FamixF77Parameter.
self assert: param name equals: 'var'.
self assert: param parentBehaviouralEntity equals: fmxEntity.
]

{ #category : #'tests - import steps' }
FortranProjectImporterTest >> testIncludedFilesToEsope [

Expand Down

0 comments on commit 348f596

Please sign in to comment.