Skip to content

Commit 137c9ce

Browse files
Added regression tests for #toHtml, #toMarkdown, #toLatex and #toString for numeric column names.
1 parent cea46c8 commit 137c9ce

1 file changed

Lines changed: 138 additions & 0 deletions

File tree

src/DataFrame-Tests/DataFrameTest.class.st

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5167,6 +5167,60 @@ DataFrameTest >> testToHtml [
51675167
self assert: df toHtml equals: expectedString
51685168
]
51695169

5170+
{ #category : #tests }
5171+
DataFrameTest >> testToHtmlWithNumericColumnNames [
5172+
5173+
| expectedString weather |
5174+
expectedString := '<table border="1" class="dataframe">
5175+
<thead>
5176+
<tr style="text-align: left;"> <th># </th>
5177+
<th>1 </th>
5178+
<th>2 </th>
5179+
<th>3 </th>
5180+
</tr>
5181+
</thead>
5182+
<tbody>
5183+
<tr> <th>''01:10''</th>
5184+
<td>2.4 </td>
5185+
<td>true </td>
5186+
<td>#rain</td>
5187+
</tr>
5188+
<tr> <th>''01:30''</th>
5189+
<td>0.5 </td>
5190+
<td>true </td>
5191+
<td>#rain</td>
5192+
</tr>
5193+
<tr> <th>''01:50''</th>
5194+
<td>-1.2</td>
5195+
<td>true </td>
5196+
<td>#snow</td>
5197+
</tr>
5198+
<tr> <th>''02:10''</th>
5199+
<td>-2.3</td>
5200+
<td>false</td>
5201+
<td>#- </td>
5202+
</tr>
5203+
<tr> <th>''02:30''</th>
5204+
<td>3.2 </td>
5205+
<td>true </td>
5206+
<td>#rain</td>
5207+
</tr>
5208+
</tbody>
5209+
</table>'.
5210+
weather := DataFrame withRows:
5211+
#( #( 2.4 true rain )
5212+
#( 0.5 true rain )
5213+
#( -1.2 true snow )
5214+
#( -2.3 false #- )
5215+
#( 3.2 true rain ) ).
5216+
5217+
weather columnNames: #( 1 2 3 ).
5218+
5219+
weather rowNames: #( '01:10' '01:30' '01:50' '02:10' '02:30' ).
5220+
5221+
self assert: weather toHtml equals: expectedString
5222+
]
5223+
51705224
{ #category : #tests }
51715225
DataFrameTest >> testToLatex [
51725226

@@ -5186,6 +5240,39 @@ DataFrameTest >> testToLatex [
51865240
self assert: df toLatex equals: expectedString
51875241
]
51885242

5243+
{ #category : #tests }
5244+
DataFrameTest >> testToLatexWithNumericColumnNames [
5245+
5246+
| expectedString weather |
5247+
expectedString := '\begin{tabular}{|l|l|l|l|}
5248+
\hline
5249+
\# & 1 & 2 & 3 \\
5250+
\hline
5251+
''01:10'' & 2.4 & true & #rain\\
5252+
\hline
5253+
''01:30'' & 0.5 & true & #rain\\
5254+
\hline
5255+
''01:50'' & -1.2 & true & #snow\\
5256+
\hline
5257+
''02:10'' & -2.3 & false & #- \\
5258+
\hline
5259+
''02:30'' & 3.2 & true & #rain\\
5260+
\hline
5261+
\end{tabular}'.
5262+
weather := DataFrame withRows:
5263+
#( #( 2.4 true rain )
5264+
#( 0.5 true rain )
5265+
#( -1.2 true snow )
5266+
#( -2.3 false #- )
5267+
#( 3.2 true rain ) ).
5268+
5269+
weather columnNames: #( 1 2 3 ).
5270+
5271+
weather rowNames: #( '01:10' '01:30' '01:50' '02:10' '02:30' ).
5272+
5273+
self assert: weather toLatex equals: expectedString
5274+
]
5275+
51895276
{ #category : #tests }
51905277
DataFrameTest >> testToMarkdown [
51915278

@@ -5199,6 +5286,32 @@ DataFrameTest >> testToMarkdown [
51995286
self assert: df toMarkdown equals: expectedString
52005287
]
52015288

5289+
{ #category : #tests }
5290+
DataFrameTest >> testToMarkdownWithNumericColumnNames [
5291+
5292+
| expectedString weather|
5293+
expectedString := '| # | 1 | 2 | 3 |
5294+
| ------- | ---- | ----- | ----- |
5295+
| ''01:10'' | 2.4 | true | #rain |
5296+
| ''01:30'' | 0.5 | true | #rain |
5297+
| ''01:50'' | -1.2 | true | #snow |
5298+
| ''02:10'' | -2.3 | false | #- |
5299+
| ''02:30'' | 3.2 | true | #rain |
5300+
'.
5301+
weather := DataFrame withRows: #(
5302+
(2.4 true rain)
5303+
(0.5 true rain)
5304+
(-1.2 true snow)
5305+
(-2.3 false -)
5306+
(3.2 true rain)).
5307+
5308+
weather columnNames: #( 1 2 3).
5309+
5310+
weather rowNames: #( '01:10' '01:30' '01:50' '02:10' '02:30').
5311+
5312+
self assert: weather toMarkdown equals: expectedString
5313+
]
5314+
52025315
{ #category : #tests }
52035316
DataFrameTest >> testToString [
52045317

@@ -5212,6 +5325,31 @@ DataFrameTest >> testToString [
52125325
self assert: df toString equals: expectedString
52135326
]
52145327

5328+
{ #category : #tests }
5329+
DataFrameTest >> testToStringWithNumericColumnNames [
5330+
5331+
| expectedString weather |
5332+
expectedString := '# 1 2 3
5333+
''01:10'' 2.4 true #rain
5334+
''01:30'' 0.5 true #rain
5335+
''01:50'' -1.2 true #snow
5336+
''02:10'' -2.3 false #-
5337+
''02:30'' 3.2 true #rain
5338+
'.
5339+
weather := DataFrame withRows:
5340+
#( #( 2.4 true rain )
5341+
#( 0.5 true rain )
5342+
#( -1.2 true snow )
5343+
#( -2.3 false #- )
5344+
#( 3.2 true rain ) ).
5345+
5346+
weather columnNames: #( 1 2 3 ).
5347+
5348+
weather rowNames: #( '01:10' '01:30' '01:50' '02:10' '02:30' ).
5349+
5350+
self assert: weather toString equals: expectedString
5351+
]
5352+
52155353
{ #category : #tests }
52165354
DataFrameTest >> testTransposed [
52175355

0 commit comments

Comments
 (0)