本文整理汇总了Scala中scala.language.postfixOps类的典型用法代码示例。如果您正苦于以下问题:Scala postfixOps类的具体用法?Scala postfixOps怎么用?Scala postfixOps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了postfixOps类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: MidiPlayerSpec
//设置package包名称以及导入依赖的类
package de.htwg.scalala.midi
import de.htwg.scalala.music.Key
import org.scalatest.WordSpec
import org.scalatest.Matchers
import scala.language.postfixOps
import de.htwg.scalala.music._
import scala.concurrent.duration._
import scala.language.postfixOps
class MidiPlayerSpec extends WordSpec {
"A MidiPlayer" should {
val midiplayer = new MidiPlayer
"play Keys encoded in midiKeys (0-127, c is key 60) for a duration in milliseconds" in {
midiplayer.play(key = 60, duration = 100 milliseconds)
Thread.sleep(100)
}
"play a set of Keys simultaneously, needed for chords" in {
val set = Set(new Key(60), new Key(64), new Key(67))
midiplayer.play(set, 75)
}
"start and stop a key with some delay inbetween. This is needed to play several keys at once." in {
midiplayer.start(60)
Thread.sleep(100)
midiplayer.stop(60)
}
"be able to change instrument" in {
midiplayer.changeToInstrument(40)
midiplayer.play(60, 100 milliseconds)
Thread.sleep(200)
}
}
}
开发者ID:markoboger,项目名称:scalala,代码行数:39,代码来源:MidiPlayerSpec.scala
示例2: DiscoveryRepositorySpec
//设置package包名称以及导入依赖的类
package com.socialthingy.plusf.p2p.discovery
import java.net.InetSocketAddress
import akka.actor.ActorSystem
import org.scalatest.{FlatSpec, Matchers}
import scala.language.postfixOps
import scala.concurrent.duration._
import scala.language.postfixOps
class DiscoveryRepositorySpec extends FlatSpec with Matchers {
val testAddr1 = new InetSocketAddress("localhost", 7000)
val testAddr2 = new InetSocketAddress("localhost", 7001)
"DiscoveryRepository" should "create a new session under a session ID it hasn't seen before" in new TestDiscoveryRepository {
connectToSession("newId", testAddr1) shouldBe None
}
it should "return the session initiator's address when a new client connects to a prior session" in new TestDiscoveryRepository {
connectToSession("newId", testAddr1)
connectToSession("newId", testAddr2) shouldBe Some(testAddr1)
}
it should "do nothing when the initiator attempts to connect to a session it has already initiated" in new TestDiscoveryRepository {
connectToSession("newId", testAddr1)
connectToSession("newId", testAddr1) shouldBe None
}
it should "clean out a session once two peers have connected" in new TestDiscoveryRepository {
connectToSession("newId", testAddr1)
connectToSession("newId", testAddr2)
connectToSession("newId", testAddr2) shouldBe None
}
it should "clean out expired sessions when scheduled cleanup takes place" in new TestDiscoveryRepository {
scheduleCleanup(1 second, 5 seconds)
connectToSession("newId", testAddr1) shouldBe None
Thread.sleep(6000)
connectToSession("newId", testAddr2) shouldBe None
}
it should "clean out a session when told to cancel it" in new TestDiscoveryRepository {
connectToSession("toBeCancelled", testAddr1) shouldBe None
cancelSession("toBeCancelled", testAddr1)
connectToSession("toBeCancelled", testAddr2) shouldBe None
}
trait TestDiscoveryRepository extends DiscoveryRepository {
val system = ActorSystem()
}
}
开发者ID:alangibson27,项目名称:plus-f,代码行数:56,代码来源:DiscoveryRepositorySpec.scala
注:本文中的scala.language.postfixOps类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论