File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed
main/kotlin/org/celtric/kotlin/html
test/kotlin/org/celtric/kotlin/html Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ buildscript {
13
13
}
14
14
15
15
group " org.celtric.kotlin"
16
- version " 0.1.0 "
16
+ version " 0.1.1 "
17
17
18
18
apply plugin : " kotlin"
19
19
apply plugin : " maven-publish"
Original file line number Diff line number Diff line change @@ -88,11 +88,6 @@ fun List<Node>.render(opt: Options = Options()) = joinToString("") {
88
88
}
89
89
90
90
operator fun List<Node>.plus (text : String ): List <Node > = plus(Text (text))
91
- // TODO: can the call to the overloaded plus operator be delegated without this casting hack?
92
- @Suppress(" UNCHECKED_CAST" )
93
- operator fun List<Node>.plus (node : Node ): List <Node > = ((this as List <Any >) + node) as List <Node >
94
- @Suppress(" UNCHECKED_CAST" )
95
- operator fun List<Node>.plus (nodes : List <Node >): List <Node > = ((this as List <Any >) + nodes) as List <Node >
96
91
97
92
// ---[ Attributes ]---------------------------------------------------------------------//
98
93
@@ -104,5 +99,5 @@ private fun Attributes.renderAttributes(prefix: String = "") =
104
99
.joinToString(" " ) { (key, value) -> " " + prefix + key + value }
105
100
106
101
class AllAttributes (val common : Attributes , val other : Attributes , val data : Attributes ) {
107
- fun render () = common.renderAttributes() + other.renderAttributes()+ data.renderAttributes(" data-" )
102
+ fun render () = common.renderAttributes() + other.renderAttributes() + data.renderAttributes(" data-" )
108
103
}
Original file line number Diff line number Diff line change @@ -38,4 +38,13 @@ internal class ListsTest {
38
38
</ul>
39
39
""" )
40
40
}
41
+
42
+ @Test fun `the way lists are grouped when combined is irrelevant` () {
43
+ val elem = li(" Element" )
44
+ val reference = elem + elem + elem + elem
45
+
46
+ ((elem) + (elem + elem + elem)).assertRendersSameAs(reference)
47
+ ((elem + elem) + (elem + elem)).assertRendersSameAs(reference)
48
+ ((elem + elem + elem) + (elem)).assertRendersSameAs(reference)
49
+ }
41
50
}
Original file line number Diff line number Diff line change @@ -19,3 +19,7 @@ fun Node.assertRendersMultiline(expected: String) {
19
19
fun List<Node>.assertRendersMultiline (expected : String ) {
20
20
Assertions .assertEquals(expected.trimIndent() + " \n " , render(testRenderingOptions))
21
21
}
22
+
23
+ fun List<Node>.assertRendersSameAs (other : List <Node >) {
24
+ Assertions .assertEquals(other.render(testRenderingOptions), render(testRenderingOptions))
25
+ }
You can’t perform that action at this time.
0 commit comments