Skip to content

Commit

Permalink
Merge pull request #361 from benjchristensen/issue-359-varargs
Browse files Browse the repository at this point in the history
Fix vararg issues reported in #359
  • Loading branch information
benjchristensen committed Sep 10, 2013
2 parents ccc10cf + af31156 commit 96feb27
Show file tree
Hide file tree
Showing 14 changed files with 1,556 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,30 @@ def class ObservableTests {
verify(a, times(1)).received("hello_2");
}

@Test
public void testFromWithIterable() {
def list = [1, 2, 3, 4, 5]
assertEquals(5, Observable.from(list).count().toBlockingObservable().single());
}

@Test
public void testFromWithObjects() {
def list = [1, 2, 3, 4, 5]
// this should now treat these as 2 objects so have a count of 2
assertEquals(2, Observable.from(list, 6).count().toBlockingObservable().single());
}

/**
* Check that two different single arg methods are selected correctly
*/
@Test
public void testStartWith() {
def list = [10, 11, 12, 13, 14]
def startList = [1, 2, 3, 4, 5]
assertEquals(6, Observable.from(list).startWith(0).count().toBlockingObservable().single());
assertEquals(10, Observable.from(list).startWith(startList).count().toBlockingObservable().single());
}

@Test
public void testScriptWithOnNext() {
new TestFactory().getObservable().subscribe({ result -> a.received(result)});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class UnitTestSuite extends JUnitSuite {
}

@Test def testSingleOrDefault {
assertEquals(0, Observable.from[Int]().toBlockingObservable.singleOrDefault(0))
assertEquals(0, Observable.empty[Int]().toBlockingObservable.singleOrDefault(0))
assertEquals(1, Observable.from(1).toBlockingObservable.singleOrDefault(0))
try {
Observable.from(1, 2, 3).toBlockingObservable.singleOrDefault(0)
Expand Down Expand Up @@ -135,8 +135,7 @@ class UnitTestSuite extends JUnitSuite {
@Test def testMerge {
val observable1 = Observable.from(1, 2, 3)
val observable2 = Observable.from(4, 5, 6)
val observableList = List(observable1, observable2).asJava
val merged = Observable.merge(observableList)
val merged = Observable.merge(observable1, observable2)
assertSubscribeReceives(merged)(1, 2, 3, 4, 5, 6)
}

Expand Down Expand Up @@ -232,13 +231,13 @@ class UnitTestSuite extends JUnitSuite {
@Test def testLastOrDefault {
val observable = Observable.from(1, 2, 3, 4)
assertEquals(4, observable.toBlockingObservable.lastOrDefault(5))
assertEquals(5, Observable.from[Int]().toBlockingObservable.lastOrDefault(5))
assertEquals(5, Observable.empty[Int]().toBlockingObservable.lastOrDefault(5))
}

@Test def testLastOrDefaultPredicate {
val observable = Observable.from(1, 2, 3, 4)
assertEquals(3, observable.toBlockingObservable.lastOrDefault(5, isOdd))
assertEquals(5, Observable.from[Int]().toBlockingObservable.lastOrDefault(5, isOdd))
assertEquals(5, Observable.empty[Int]().toBlockingObservable.lastOrDefault(5, isOdd))
}

@Test def testMap {
Expand Down
Loading

0 comments on commit 96feb27

Please sign in to comment.