From 9cba3968532c03b7f659c20fbc8a4e6a1eba34f9 Mon Sep 17 00:00:00 2001 From: uNouss Date: Wed, 31 Jul 2024 14:30:19 +0200 Subject: [PATCH] Fix error occuring by testing from fortran source instead of json ast --- .../IASTToFamixVisitorTest.class.st | 53 ++++++++++++++++++- .../JsonToIASTVisitorTest.class.st | 24 +++++---- 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/src/EsopeImporter-Tests/IASTToFamixVisitorTest.class.st b/src/EsopeImporter-Tests/IASTToFamixVisitorTest.class.st index 5f2ba44..87fbd44 100644 --- a/src/EsopeImporter-Tests/IASTToFamixVisitorTest.class.st +++ b/src/EsopeImporter-Tests/IASTToFamixVisitorTest.class.st @@ -8,7 +8,7 @@ Class { 'visitor', 'programFile' ], - #category : 'EsopeImporter-Tests-Visitor' + #category : #'EsopeImporter-Tests-Visitor' } { #category : #running } @@ -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 [ diff --git a/src/EsopeImporter-Tests/JsonToIASTVisitorTest.class.st b/src/EsopeImporter-Tests/JsonToIASTVisitorTest.class.st index 869179a..2636c85 100644 --- a/src/EsopeImporter-Tests/JsonToIASTVisitorTest.class.st +++ b/src/EsopeImporter-Tests/JsonToIASTVisitorTest.class.st @@ -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":""},"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. @@ -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":""},"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. @@ -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":""},"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.