Skip to content

Commit

Permalink
Refactored to #assertIntDeclaration: as suggested by Nahuel
Browse files Browse the repository at this point in the history
  • Loading branch information
Hernán Morales Durand committed Aug 1, 2023
1 parent c4dacc6 commit 74d318c
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions smalltalksrc/CAST/CASTParserTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ void f() {
ex resume: ex tag first ]
]

{ #category : #'tests-declarators' }
CASTParserTests >> assertIntDeclaration: aDeclaration [

| declarationSpecifiers |
declarationSpecifiers := aDeclaration specifiers.

self assert: declarationSpecifiers first value equals: 'int'.
self assert: aDeclaration declarators size equals: 1.
]

{ #category : #helpers }
CASTParserTests >> parseDeclaration: aStratement [

Expand Down Expand Up @@ -373,13 +383,10 @@ CASTParserTests >> testParseFloatingPointConstant [
{ #category : #'tests-declarators' }
CASTParserTests >> testParseFunctionDeclarator [

| declaration declarator declarationSpecifiers |
| declaration declarator |
declaration := self parseDeclaration: 'int f(void)'.
declarationSpecifiers := declaration specifiers.

self assert: declarationSpecifiers first value equals: 'int'.
self assert: declaration declarators size equals: 1.

self assertIntDeclaration: declaration.
declarator := declaration declarators first.
self assert: declarator isFunctionDeclarator.
self assert: declarator declarator name equals: 'f'.
Expand All @@ -389,13 +396,10 @@ CASTParserTests >> testParseFunctionDeclarator [
{ #category : #'tests-declarators' }
CASTParserTests >> testParseFunctionPointerDeclarator [

| declaration declarator declarationSpecifiers |
| declaration declarator |
declaration := self parseDeclaration: 'int (*pf)(void)'.
declarationSpecifiers := declaration specifiers.

self assert: declarationSpecifiers first value equals: 'int'.
self assert: declaration declarators size equals: 1.

self assertIntDeclaration: declaration.
declarator := declaration declarators first.
self assert: declarator isFunctionDeclarator.
self assert: declarator declarator isPointerDeclarator.
Expand Down Expand Up @@ -629,12 +633,10 @@ CASTParserTests >> testParseParenthesizedExpression [
{ #category : #'tests-declarators' }
CASTParserTests >> testParsePointerDeclarator [

| declaration declarator declarationSpecifiers |
| declaration declarator |

declaration := self parseDeclaration: 'int *a'.
declarationSpecifiers := declaration specifiers.

self assert: declarationSpecifiers first value equals: 'int'.
self assert: declaration declarators size equals: 1.
self assertIntDeclaration: declaration.

declarator := declaration declarators first.
self assert: declarator isPointerDeclarator.
Expand Down Expand Up @@ -694,12 +696,9 @@ CASTParserTests >> testParseSequenceOfDeclarators [
{ #category : #'tests-declarators' }
CASTParserTests >> testParseSimpleArrayDeclaration [

| declaration declarator declarationSpecifiers |
| declaration declarator |
declaration := self parseDeclaration: 'int a[]'.
declarationSpecifiers := declaration specifiers.

self assert: declarationSpecifiers first value equals: 'int'.
self assert: declaration declarators size equals: 1.
self assertIntDeclaration: declaration.

declarator := declaration declarators first.
self assert: declarator isArrayDeclarator.
Expand Down

0 comments on commit 74d318c

Please sign in to comment.