var script: RrbTree<out Event>
instaed
.fold(RrbTree.emptyMutable<Event>()) { events, line ->
events.append(parseLine(line))
}.immutable()
package org.organicdesign.fp.collections
import junit.framework.TestCase.assertEquals
import org.junit.Test
class RrbTreeKotlinTest {
sealed class Event {
enum class HTTPEventType { REQ, REQ_HOME, REQ_SINF, REQ_TOK }
data class HTTPEvent(val type: HTTPEventType) : Event()
enum class WSEventType { WS_OPEN, WS_RECV, WS_RECV_INIT, WS_SEND }
data class WSEvent(val type: WSEventType) : Event()
}
fun parseLine(i: Int): Event =
if (i % 2 == 1) {
Event.HTTPEvent(Event.HTTPEventType.values()[i%4])
} else {
Event.WSEvent(Event.WSEventType.values()[i%4])
}
val numItems:Int = 5000
@Test
fun testTypeArrays() {
val test:kotlin.collections.List<Int> = (1 .. numItems).toList()
// println("test=$test")
val test2: RrbTree<Event> = test.asSequence()
.fold(RrbTree.empty<Event>(),
{ events, line -> events.append(parseLine(line)) })
// println("test2=$test2")
assertEquals(numItems, test2.size)
}
}
@alandipert I'm sorry, but I can't reproduce this issue. I added the following test to the exact commit of your project that you referenced:
@Test fun testReadEventLog() {
val events = readEventLog("src/test/resources/testFile")
// println("events=$events")
assertEquals(2400, events.size)
val event0 = events[0]
assertEquals(HTTPEvent::class, event0::class)
val event1 = events[1800]
assertEquals(WSEvent::class, event1::class)
}
And removed "out" from the type signature in your project, and it still worked. Here's the test file I used: https://pastebin.com/txepakng
I'm going to work on something else unless I hear from you. Nice to hear from you again. Happy new year!