Skip to content

Commit ea6952b

Browse files
committed
Merge pull request #115 from xuwei-k/travis-ci
add travis-ci settings. fix some scalacheck tests
2 parents 7e68684 + 245ea69 commit ea6952b

7 files changed

Lines changed: 39 additions & 19 deletions

File tree

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: java
2+
3+
sudo: false
4+
5+
jdk:
6+
- oraclejdk8
7+
8+
script:
9+
- jdk_switcher use oraclejdk7 && export JAVA7_HOME=$JAVA_HOME
10+
- jdk_switcher use oraclejdk8 && export JAVA8_HOME=$JAVA_HOME
11+
- ./gradlew build --stacktrace --info

README.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
= Functional Java
22

3+
image:https://travis-ci.org/functionaljava/functionaljava.svg?branch=master["Build Status", link="https://travis-ci.org/functionaljava/functionaljava"]
4+
35
image::http://www.functionaljava.org/img/logo-600x144.png[]
46

57
Functional Java is an open source library facilitating functional programming in Java. The library implements numerous basic and advanced programming abstractions that assist composition oriented development. Functional Java also serves as a platform for learning functional programming concepts by introducing these concepts using a familiar language.
@@ -98,4 +100,4 @@ A more complete description of the features mentioned above are:
98100

99101
== License
100102

101-
link:etc/LICENCE[The Functional Java license] uses the BSD 3 license (3-clause license) available at https://en.wikipedia.org/wiki/BSD_licenses[].
103+
link:etc/LICENCE[The Functional Java license] uses the BSD 3 license (3-clause license) available at https://en.wikipedia.org/wiki/BSD_licenses[].

tests/src/test/scala/fj/Tests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object Tests {
2929

3030
def run(tests: List[(String, Prop)]) =
3131
tests foreach { case (name, p) => {
32-
val c = check(new Test.Parameters.Default { }, p)
32+
val c = check(new Test.Parameters.Default { override val maxSize = 20 }, p)
3333
c.status match {
3434
case Test.Passed => println("Passed " + name)
3535
case Test.Proved(_) => println("Proved " + name)

tests/src/test/scala/fj/data/CheckArray.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ object CheckArray extends Properties("Array") {
107107
a.reverse.reverse,
108108
a))
109109

110-
property("reverse") = forAll((a: Array[String], n: Int) =>
111-
(n >= 0 && n < a.length) ==>
112-
(a.reverse.get(n) == a.get(a.length - 1 - n)))
110+
property("reverse") = forAll((a: Array[String], x: Byte) =>
111+
(a.length > 0) ==> {
112+
val n = math.abs(x) % a.length
113+
(a.reverse.get(n) == a.get(a.length - 1 - n))
114+
})
113115

114116
property("appendLeftIdentity") = forAll((a: Array[String]) =>
115117
arrayEqual(stringEqual).eq(a.append(empty[String]), a))
@@ -123,9 +125,11 @@ object CheckArray extends Properties("Array") {
123125
property("appendLength") = forAll((a: Array[String], b: Array[String]) =>
124126
a.append(b).length == a.length + b.length)
125127

126-
property("array") = forAll((a: scala.Array[String], n: Int) =>
127-
(n >= 0 && n < a.length) ==>
128-
(array[String](a: _*).length == a.length && array[String](a: _*).get(n) == a(n)))
128+
property("array") = forAll((a: scala.Array[String], x: Byte) =>
129+
(a.length > 0) ==> {
130+
val n = math.abs(x) % a.length
131+
array[String](a: _*).length == a.length && array[String](a: _*).get(n) == a(n)
132+
})
129133

130134
property("join") = forAll((a: Array[Array[String]]) =>
131135
arrayEqual(stringEqual).eq(

tests/src/test/scala/fj/data/CheckIteratee.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ object CheckIteratee extends Properties("Iteratee") {
2727
property("head") = forAll((a: List[Int]) =>
2828
enumerate(a, IterV.head[Int]).run == a.toOption)
2929

30-
property("drop") = forAll((a: List[String], n: Int) => {
31-
(n >= 0 && n <= a.length) ==> {
32-
val actual = enumerate(a, IterV.drop(n).bind(Function.constant(IterV.list[String]))).run.reverse
33-
listEqual(stringEqual).eq(actual, a.drop(n))
34-
}
30+
property("drop") = forAll((a: List[String], x: Byte) => (a.length > 0) ==> {
31+
val n = math.abs(x) % a.length
32+
val actual = enumerate(a, IterV.drop(n).bind(Function.constant(IterV.list[String]))).run.reverse
33+
listEqual(stringEqual).eq(actual, a.drop(n))
3534
})
3635

3736
property("list") = forAll((a: List[String]) =>

tests/src/test/scala/fj/data/CheckList.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ object CheckList extends Properties("List") {
118118
(a append b).reverse,
119119
b.reverse.append(a.reverse)))
120120

121-
property("index") = forAll((a: List[String], n: Int) =>
122-
(n > 0 && n < a.length) ==>
123-
(a.index(n) == a.tail.index(n - 1)))
121+
property("index") = forAll((a: List[String], x: Byte) =>
122+
(a.length > 0) ==> {
123+
val n = math.abs(x) % a.length + 1
124+
(n < a.length) ==> (a.index(n) == a.tail.index(n - 1))
125+
})
124126

125127
property("snoc") = forAll((a: List[String], s: String) =>
126128
listEqual(stringEqual).eq(

tests/src/test/scala/fj/data/CheckStream.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ object CheckStream extends Properties("Stream") {
128128
(a append b).reverse,
129129
b.reverse.append(a.reverse)))
130130

131-
property("index") = forAll((a: Stream[String], n: Int) =>
132-
(n > 0 && n < a.length) ==>
133-
(a.index(n) == a.tail._1.index(n - 1)))
131+
property("index") = forAll((a: Stream[String], x: Byte) =>
132+
(a.length > 0) ==> {
133+
val n = math.abs(x) % a.length + 1
134+
(n < a.length) ==> (a.index(n) == a.tail._1.index(n - 1))
135+
})
134136

135137
property("forall") = forAll((a: Stream[Int]) =>
136138
a.forall((x: Int) => ((x % 2 == 0): java.lang.Boolean)) ==

0 commit comments

Comments
 (0)