Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions project/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
project.organization=com.twitter
project.name=util
sbt.version=0.7.5
project.version=1.10.3-SNAPSHOT
project.version=2.9.0-1_1.10.3-SNAPSHOT
def.scala.version=2.7.7
build.scala.versions=2.8.1
build.scala.versions=2.9.0-1
project.initialize=false
4 changes: 2 additions & 2 deletions project/build/Project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Project(info: ProjectInfo)
extends StandardProject(info)
with ProjectDefaults
{
val scalaTools = "org.scala-lang" % "scala-compiler" % "2.8.1" % "compile"
val scalaTools = "org.scala-lang" % "scala-compiler" % "2.9.0-1" % "compile"
override def filterScalaJars = false
}

Expand Down Expand Up @@ -97,7 +97,7 @@ class Project(info: ProjectInfo)
with ProjectDependencies
with DefaultRepos
{
val specs = "org.scala-tools.testing" % "specs_2.8.0" % "1.6.5" % "test" withSources()
val specs = "org.scala-tools.testing" % "specs_2.9.0-1" % "1.6.8" % "test" withSources()
val mockito = "org.mockito" % "mockito-all" % "1.8.5" % "test" withSources()
val junit = "junit" % "junit" % "3.8.2" % "test"

Expand Down
48 changes: 24 additions & 24 deletions util-core/src/test/scala/com/twitter/util/FutureSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.twitter.conversions.time._
import java.util.concurrent.ConcurrentLinkedQueue
import com.twitter.concurrent.SimpleSetter

object FutureSpec extends Specification with Mockito {
class FutureSpec extends Specification with Mockito {
"Future" should {
import Future._

Expand Down Expand Up @@ -390,39 +390,39 @@ object FutureSpec extends Specification with Mockito {
}
}

"FutureTask" should {
"return result" in {
"FutureTask" in {
"should return result" in {
val task = new FutureTask("hello")
task.run()
task() mustEqual "hello"
}

"throw result" in {
"should throw result" in {
val task = new FutureTask[String](throw new IllegalStateException)
task.run()
task() must throwA(new IllegalStateException)
}
}

"Future.select()" should {
"Future.select()" in {
val p0 = new Promise[Int]
val p1 = new Promise[Int]
val f = p0 select p1
f.isDefined must beFalse

"select the first [result] to complete" in {
"should select the first [result] to complete" in {
p0() = Return(1)
p1() = Return(2)
f() must be_==(1)
}

"select the first [exception] to complete" in {
"should select the first [exception] to complete" in {
p0() = Throw(new Exception)
p1() = Return(2)
f() must throwA[Exception]
}

"propagate cancellation" in {
"should propagate cancellation" in {
p0.isCancelled must beFalse
p1.isCancelled must beFalse
f.cancel()
Expand All @@ -431,20 +431,20 @@ object FutureSpec extends Specification with Mockito {
}
}

"Future.join()" should {
"Future.join()" in {
val p0 = new Promise[Int]
val p1 = new Promise[Int]
val f = p0 join p1
f.isDefined must beFalse

"only return when both futures complete" in {
"should only return when both futures complete" in {
p0() = Return(1)
f.isDefined must beFalse
p1() = Return(2)
f() must be_==(1, 2)
}

"return with exception if the first future throws" in {
"should return with exception if the first future throws" in {
p0() = Throw(new Exception)
f() must throwA[Exception]
}
Expand All @@ -465,32 +465,32 @@ object FutureSpec extends Specification with Mockito {
}
}

"Future.collect()" should {
"Future.collect()" in {
val p0 = new Promise[Int]
val p1 = new Promise[Int]
val f = Future.collect(Seq(p0, p1))
f.isDefined must beFalse

"only return when both futures complete" in {
"should only return when both futures complete" in {
p0() = Return(1)
f.isDefined must beFalse
p1() = Return(2)
f() must be_==(Seq(1, 2))
}

"return with exception if the first future throws" in {
"should return with exception if the first future throws" in {
p0() = Throw(new Exception)
f() must throwA[Exception]
}

"return with exception if the second future throws" in {
"should return with exception if the second future throws" in {
p0() = Return(1)
f.isDefined must beFalse
p1() = Throw(new Exception)
f() must throwA[Exception]
}

"propagate cancellation" in {
"should propagate cancellation" in {
p0.isCancelled must beFalse
p1.isCancelled must beFalse
f.cancel()
Expand All @@ -499,9 +499,9 @@ object FutureSpec extends Specification with Mockito {
}
}

"Future.select()" should {
"Future.select()" in {

"return the first result" in {
"should return the first result" in {
def tryBothForIndex(i: Int) = {
"success (%d)".format(i) in {
val fs = (0 until 10 map { _ => new Promise[Int] }) toArray
Expand All @@ -518,7 +518,7 @@ object FutureSpec extends Specification with Mockito {
}
}

"failure (%d)".format(i) in {
"should failure (%d)".format(i) in {
val fs = (0 until 10 map { _ => new Promise[Int] }) toArray
val f = Future.select(fs)
f.isDefined must beFalse
Expand All @@ -539,13 +539,13 @@ object FutureSpec extends Specification with Mockito {
0 until 10 foreach { tryBothForIndex(_) }
}

"fail if we attempt to select an empty future sequence" in {
"should fail if we attempt to select an empty future sequence" in {
val f = Future.select(Seq())
f.isDefined must beTrue
f() must throwA(new IllegalArgumentException("empty future list!"))
}

"propagate cancellation" in {
"should propagate cancellation" in {
val fs = (0 until 10 map { _ => new Promise[Int] }) toArray;
Future.select(fs).cancel()
fs foreach { f =>
Expand All @@ -554,8 +554,8 @@ object FutureSpec extends Specification with Mockito {
}
}

"Future.toOffer" should {
"activate when future is satisfied (poll)" in {
"Future.toOffer" in {
"should activate when future is satisfied (poll)" in {
val p = new Promise[Int]
val o = p.toOffer
o.poll() must beNone
Expand All @@ -566,7 +566,7 @@ object FutureSpec extends Specification with Mockito {
}
}

"activate when future is satisfied (enqueue)" in {
"should activate when future is satisfied (enqueue)" in {
val p = new Promise[Int]
val o = p.toOffer
val s = new SimpleSetter[Try[Int]]
Expand Down
7 changes: 3 additions & 4 deletions util-core/src/test/scala/com/twitter/util/U64Spec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ class U64Spec extends Specification {
0x8000000000000000L.u64_/(3) must be_==(0x2AAAAAAAAAAAAAAAL)
}

"ids" should {
"survive conversions" in {
"ids should survive conversions" in {
val rng = new Random

(0 until 10000).foreach { _ =>
Expand All @@ -101,10 +100,10 @@ class U64Spec extends Specification {
}
}

"be serializable" in {
"ids should be serializable" in {
0L.toU64HexString must be_==("0000000000000000")
0x0102030405060700L.toU64HexString must be_==("0102030405060700")
0xFFF1F2F3F4F5F6F7L.toU64HexString must be_==("fff1f2f3f4f5f6f7")
}
}

}