Skip to content

Commit ea85355

Browse files
committed
Merge pull request #20 from EddieRingle/kotlin-m12
Update to Kotlin M12
2 parents 1534db5 + 144e1c4 commit ea85355

File tree

9 files changed

+73
-73
lines changed

9 files changed

+73
-73
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
buildscript {
22
repositories { jcenter() }
33
dependencies { classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:2.+',
4-
'org.jetbrains.kotlin:kotlin-gradle-plugin:0.11.+' }
4+
'org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.+' }
55
}
66

77
apply plugin: 'rxjava-project'
88
apply plugin: 'kotlin'
99

1010
dependencies {
1111
compile 'io.reactivex:rxjava:1.0.+'
12-
compile 'org.jetbrains.kotlin:kotlin-stdlib:0.11.+'
13-
compile 'org.funktionale:funktionale:0.4.2_M11'
12+
compile 'org.jetbrains.kotlin:kotlin-stdlib:0.12.+'
13+
compile 'org.funktionale:funktionale:0.5.1_M12'
1414
testCompile 'junit:junit:4.12'
1515
testCompile 'org.mockito:mockito-core:1.8.5'
1616
examplesCompile 'com.squareup.retrofit:retrofit:1.9.+'

src/examples/kotlin/rx/lang/kotlin/examples/examples.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import rx.lang.kotlin.onError
1010

1111
fun main(args: Array<String>) {
1212

13-
val printArticle = {(art: String) ->
13+
val printArticle = { art: String ->
1414
println("--- Article ---\n${art.substring(0, 125)}")
1515
}
1616

17-
val printIt = {(it: String) -> println(it) }
17+
val printIt = { it: String -> println(it) }
1818

1919
asyncObservable().subscribe(printIt)
2020

src/examples/kotlin/rx/lang/kotlin/examples/retrofit.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data class SearchResultEntry(val id : String, val latestVersion : String)
1010
data class SearchResults(val docs : List<SearchResultEntry>)
1111
data class MavenSearchResponse(val response : SearchResults)
1212

13-
trait MavenSearchService {
13+
interface MavenSearchService {
1414
GET("/solrsearch/select?wt=json")
1515
fun search(Query("q") s : String, Query("rows") rows : Int = 20) : Observable<MavenSearchResponse>
1616
}

src/main/kotlin/rx/lang/kotlin/observables.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public fun <T> Array<out T>.toObservable() : Observable<T> = Observable.from(thi
2727

2828
public fun Progression<Int>.toObservable() : Observable<Int> =
2929
if (increment == 1 && end.toLong() - start < Integer.MAX_VALUE) Observable.range(start, Math.max(0, end - start + 1))
30-
else (this : Iterable<Int>).toObservable()
30+
else Observable.from(this)
3131

3232
public fun <T> Iterator<T>.toObservable() : Observable<T> = toIterable().toObservable()
3333
public fun <T> Iterable<T>.toObservable() : Observable<T> = Observable.from(this)
3434
public fun <T> Sequence<T>.toObservable() : Observable<T> = Observable.from(object : Iterable<T> {
3535
override fun iterator(): Iterator<T> = this@toObservable.iterator()
36-
}) : Observable<T>
36+
})
3737

3838
public fun <T> T.toSingletonObservable() : Observable<T> = Observable.just(this)
3939
public fun <T> Throwable.toObservable() : Observable<T> = Observable.error(this)
@@ -44,11 +44,11 @@ public fun <T> Iterable<Observable<out T>>.mergeDelayError() : Observable<T> = O
4444

4545
public fun <T, R> Observable<T>.fold(initial : R, body : (R, T) -> R) : Observable<R> = reduce(initial, {a, e -> body(a, e)})
4646
public fun <T> Observable<T>.onError(block : (Throwable) -> Unit) : Observable<T> = doOnError(block)
47-
[suppress("BASE_WITH_NULLABLE_UPPER_BOUND")]
47+
@suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
4848
public fun <T> Observable<T>.firstOrNull() : Observable<T?> = firstOrDefault(null)
4949
public fun <T> BlockingObservable<T>.firstOrNull() : T = firstOrDefault(null)
5050

51-
[suppress("BASE_WITH_NULLABLE_UPPER_BOUND")]
51+
@suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
5252
public fun <T> Observable<T>.onErrorReturnNull() : Observable<T?> = onErrorReturn {null}
5353

5454
public fun <T, R> Observable<T>.lift(operator : (Subscriber<in R>) -> Subscriber<T>) : Observable<R> = lift(object : Observable.Operator<R, T> {

src/test/kotlin/rx/lang/kotlin/BasicKotlinTests.kt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import rx.Subscriber
3333
public class BasicKotlinTests : KotlinTests() {
3434

3535

36-
[Test]
36+
@Test
3737
public fun testCreate() {
3838

3939
Observable.create(object:OnSubscribe<String> {
@@ -48,46 +48,46 @@ public class BasicKotlinTests : KotlinTests() {
4848
verify(a, times(1)).received("Hello")
4949
}
5050

51-
[Test]
51+
@Test
5252
public fun testFilter() {
5353
Observable.from(listOf(1, 2, 3)).filter { it >= 2 }.subscribe(received)
5454
verify(a, times(0)).received(1);
5555
verify(a, times(1)).received(2);
5656
verify(a, times(1)).received(3);
5757
}
5858

59-
[Test]
59+
@Test
6060
public fun testLast() {
6161
assertEquals("three", Observable.from(listOf("one", "two", "three")).toBlocking().last())
6262
}
6363

64-
[Test]
64+
@Test
6565
public fun testLastWithPredicate() {
6666
assertEquals("two", Observable.from(listOf("one", "two", "three")).toBlocking().last { x -> x.length() == 3 })
6767
}
6868

69-
[Test]
69+
@Test
7070
public fun testMap1() {
7171
Observable.just(1).map { v -> "hello_$v" }.subscribe(received)
7272
verify(a, times(1)).received("hello_1")
7373
}
7474

75-
[Test]
75+
@Test
7676
public fun testMap2() {
7777
Observable.from(listOf(1, 2, 3)).map { v -> "hello_$v" }.subscribe(received)
7878
verify(a, times(1)).received("hello_1")
7979
verify(a, times(1)).received("hello_2")
8080
verify(a, times(1)).received("hello_3")
8181
}
8282

83-
[Test]
83+
@Test
8484
public fun testMaterialize() {
8585
Observable.from(listOf(1, 2, 3)).materialize().subscribe(received)
8686
verify(a, times(4)).received(any(javaClass<Notification<Int>>()))
8787
verify(a, times(0)).error(any(javaClass<Exception>()))
8888
}
8989

90-
[Test]
90+
@Test
9191
public fun testMerge() {
9292
Observable.merge(
9393
Observable.from(listOf(1, 2, 3)),
@@ -108,139 +108,139 @@ public class BasicKotlinTests : KotlinTests() {
108108
verify(a, times(1)).error(any(javaClass<NullPointerException>()))
109109
}
110110

111-
[Test]
111+
@Test
112112
public fun testScriptWithMaterialize() {
113113
TestFactory().observable.materialize().subscribe(received)
114114
verify(a, times(2)).received(any(javaClass<Notification<Int>>()))
115115
}
116116

117-
[Test]
117+
@Test
118118
public fun testScriptWithMerge() {
119119
val factory = TestFactory()
120120
Observable.merge(factory.observable, factory.observable).subscribe(received)
121121
verify(a, times(1)).received("hello_1")
122122
verify(a, times(1)).received("hello_2")
123123
}
124124

125-
[Test]
125+
@Test
126126
public fun testFromWithIterable() {
127127
val list = listOf(1, 2, 3, 4, 5)
128128
assertEquals(5, Observable.from(list).count().toBlocking().single())
129129
}
130130

131-
[Test]
131+
@Test
132132
public fun testFromWithObjects() {
133133
val list = listOf(1, 2, 3, 4, 5)
134134
assertEquals(2, Observable.from(listOf(list, 6)).count().toBlocking().single())
135135
}
136136

137-
[Test]
137+
@Test
138138
public fun testStartWith() {
139139
val list = listOf(10, 11, 12, 13, 14)
140140
val startList = listOf(1, 2, 3, 4, 5)
141141
assertEquals(6, Observable.from(list).startWith(0).count().toBlocking().single())
142142
assertEquals(10, Observable.from(list).startWith(startList).count().toBlocking().single())
143143
}
144144

145-
[Test]
145+
@Test
146146
public fun testScriptWithOnNext() {
147147
TestFactory().observable.subscribe(received)
148148
verify(a, times(1)).received("hello_1")
149149
}
150150

151-
[Test]
151+
@Test
152152
public fun testSkipTake() {
153153
Observable.from(listOf(1, 2, 3)).skip(1).take(1).subscribe(received)
154154
verify(a, times(0)).received(1)
155155
verify(a, times(1)).received(2)
156156
verify(a, times(0)).received(3)
157157
}
158158

159-
[Test]
159+
@Test
160160
public fun testSkip() {
161161
Observable.from(listOf(1, 2, 3)).skip(2).subscribe(received)
162162
verify(a, times(0)).received(1)
163163
verify(a, times(0)).received(2)
164164
verify(a, times(1)).received(3)
165165
}
166166

167-
[Test]
167+
@Test
168168
public fun testTake() {
169169
Observable.from(listOf(1, 2, 3)).take(2).subscribe(received)
170170
verify(a, times(1)).received(1)
171171
verify(a, times(1)).received(2)
172172
verify(a, times(0)).received(3)
173173
}
174174

175-
[Test]
175+
@Test
176176
public fun testTakeLast() {
177177
TestFactory().observable.takeLast(1).subscribe(received)
178178
verify(a, times(1)).received("hello_1")
179179
}
180180

181-
[Test]
181+
@Test
182182
public fun testTakeWhile() {
183183
Observable.from(listOf(1, 2, 3)).takeWhile { x -> x < 3 }.subscribe(received)
184184
verify(a, times(1)).received(1)
185185
verify(a, times(1)).received(2)
186186
verify(a, times(0)).received(3)
187187
}
188188

189-
[Test]
189+
@Test
190190
public fun testTakeWhileWithIndex() {
191191
Observable.from(listOf(1, 2, 3)).takeWhile { x -> x < 3 }.zipWith(Observable.range(0,Integer.MAX_VALUE)){ x, i -> x }.subscribe(received)
192192
verify(a, times(1)).received(1)
193193
verify(a, times(1)).received(2)
194194
verify(a, times(0)).received(3)
195195
}
196196

197-
[Test]
197+
@Test
198198
public fun testToSortedList() {
199199
TestFactory().numbers.toSortedList().subscribe(received)
200200
verify(a, times(1)).received(listOf(1, 2, 3, 4, 5))
201201
}
202202

203-
[Test]
203+
@Test
204204
public fun testForEach() {
205205
Observable.create(AsyncObservable()).toBlocking().forEach(received)
206206
verify(a, times(1)).received(1)
207207
verify(a, times(1)).received(2)
208208
verify(a, times(1)).received(3)
209209
}
210210

211-
[Test(expected = javaClass<RuntimeException>())]
211+
@Test(expected = RuntimeException::class)
212212
public fun testForEachWithError() {
213213
Observable.create(AsyncObservable()).toBlocking().forEach { throw RuntimeException("err") }
214214
fail("we expect an exception to be thrown")
215215
}
216216

217-
[Test]
217+
@Test
218218
public fun testLastOrDefault() {
219219
assertEquals("two", Observable.from(listOf("one", "two")).toBlocking().lastOrDefault("default") { x -> x.length() == 3 })
220220
assertEquals("default", Observable.from(listOf("one", "two")).toBlocking().lastOrDefault("default") { x -> x.length() > 3 })
221221
}
222222

223-
[Test(expected = javaClass<IllegalArgumentException>())]
223+
@Test(expected = IllegalArgumentException::class)
224224
public fun testSingle() {
225225
assertEquals("one", Observable.just("one").toBlocking().single { x -> x.length() == 3 })
226226
Observable.from(listOf("one", "two")).toBlocking().single { x -> x.length() == 3 }
227227
fail()
228228
}
229229

230-
[Test]
230+
@Test
231231
public fun testDefer() {
232232
Observable.defer { Observable.from(listOf(1, 2)) }.subscribe(received)
233233
verify(a, times(1)).received(1)
234234
verify(a, times(1)).received(2)
235235
}
236236

237-
[Test]
237+
@Test
238238
public fun testAll() {
239239
Observable.from(listOf(1, 2, 3)).all { x -> x > 0 }.subscribe(received)
240240
verify(a, times(1)).received(true)
241241
}
242242

243-
[Test]
243+
@Test
244244
public fun testZip() {
245245
val o1 = Observable.from(listOf(1, 2, 3))
246246
val o2 = Observable.from(listOf(4, 5, 6))
@@ -252,7 +252,7 @@ public class BasicKotlinTests : KotlinTests() {
252252
assertEquals(listOf(3, 6, 9), values[2])
253253
}
254254

255-
[Test]
255+
@Test
256256
public fun testZipWithIterable() {
257257
val o1 = Observable.from(listOf(1, 2, 3))
258258
val o2 = Observable.from(listOf(4, 5, 6))
@@ -264,7 +264,7 @@ public class BasicKotlinTests : KotlinTests() {
264264
assertEquals(listOf(3, 6, 9), values[2])
265265
}
266266

267-
[Test]
267+
@Test
268268
public fun testGroupBy() {
269269
var count = 0
270270

0 commit comments

Comments
 (0)