Skip to content

Commit

Permalink
Adding some tests + make sure that we can ask any element about the f…
Browse files Browse the repository at this point in the history
…ile it was placed on
  • Loading branch information
Ducasse committed May 21, 2024
1 parent e8098c3 commit cc8fc77
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/Microdown-Tests/MicrodownTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,29 @@ A MicrodownTest is a test class for testing the behavior of Microdown
Class {
#name : 'MicrodownTest',
#superclass : 'TestCase',
#instVars : [
'file',
'filesystem'
],
#category : 'Microdown-Tests-Core',
#package : 'Microdown-Tests',
#tag : 'Core'
}

{ #category : 'running' }
MicrodownTest >> setUp [
super setUp.
filesystem := FileSystem memory.
file := filesystem workingDirectory / 'anExample1.md'.
file writeStreamDo: [ :stream | stream nextPutAll: '# Foo
Pharo is cool

```
this is a code snippet
```
' ].
]

{ #category : 'tests - parent/children' }
MicrodownTest >> testAddedAsChildWhenUsingParent [

Expand Down Expand Up @@ -45,6 +63,34 @@ MicrodownTest >> testFigureLabelAreNotReified [

]

{ #category : 'tests' }
MicrodownTest >> testFromFileIfAbsent [

| root |
root := Microdown parse: (filesystem workingDirectory / 'anExample1.md') contents.
self deny: root hasFile
]

{ #category : 'tests' }
MicrodownTest >> testFromFileInAnyElement [

| root |
root := Microdown parseFile: filesystem workingDirectory / 'anExample1.md'.
self assert: root children first children first fromFile equals: (filesystem workingDirectory / 'anExample1.md') fullName


]

{ #category : 'tests' }
MicrodownTest >> testFromFileInRootDocument [

| root |
root := Microdown parseFile: filesystem workingDirectory / 'anExample1.md'.
self assert: root fromFile equals: (filesystem workingDirectory / 'anExample1.md') fullName


]

{ #category : 'tests - parent/children' }
MicrodownTest >> testMathCaptionIsReified [
"And as such their parent is the math block"
Expand Down
6 changes: 6 additions & 0 deletions src/Microdown/MicElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ MicElement >> basicParent: aMicBlock [
parent := aMicBlock
]

{ #category : 'accessing' }
MicElement >> fromFile [
"Let us bubble up to the root to get the file"
^ self parent fromFile
]

{ #category : 'properties' }
MicElement >> hasProperty: aKey [
"Answer whether there is a property named aKey."
Expand Down
5 changes: 5 additions & 0 deletions src/Microdown/MicRootBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ MicRootBlock >> fromFile: aFile [
self propertyAt: #file put: aFile
]

{ #category : 'testing' }
MicRootBlock >> hasFile [
^ self hasProperty: #file
]

{ #category : 'accessing' }
MicRootBlock >> indent [
^0
Expand Down

0 comments on commit cc8fc77

Please sign in to comment.