本文整理汇总了Scala中org.scalactic.TypeCheckedTripleEquals类的典型用法代码示例。如果您正苦于以下问题:Scala TypeCheckedTripleEquals类的具体用法?Scala TypeCheckedTripleEquals怎么用?Scala TypeCheckedTripleEquals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeCheckedTripleEquals类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: Demo2Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{FunSpec, Matchers}
// DEMO 2 - use assume with an ensuring that compares with math.sqrt
class Demo2Spec extends FunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRootB function") {
it("should compute the square root") {
forAll { (x: Double) =>
whenever (x >= 0.0 && !x.isPosInfinity) {
noException should be thrownBy { squareRootB(x) }
}
}
}
it("should should throw IAE on negative input") {
an [AssertionError] should be thrownBy {
squareRootB(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [AssertionError] should be thrownBy {
squareRootB(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:33,代码来源:Demo2Spec.scala
示例2: Demo11Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalactic.anyvals.PosZDouble
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{LogicFunSpec, Matchers}
// (Demo 10 - PosInt in the REPL)
// DEMO 11 - Use PosZInt to weaken the require?
// Only input is changed to PosZDouble so far.
class Demo11Spec extends LogicFunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
forAll { (x: PosZDouble) =>
whenever (!x.isPosInfinity) {
squareRoot2(x) should === (math.sqrt(x))
}
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:37,代码来源:Demo11Spec.scala
示例3: BasketSpec
//设置package包名称以及导入依赖的类
import akka.Done
import akka.actor.ActorSystem
import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry
import com.lightbend.lagom.scaladsl.testkit.PersistentEntityTestDriver
import demo.api.basket.{Basket, Item}
import demo.impl.basket._
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import scala.concurrent.duration._
import scala.concurrent.Await
class BasketSpec extends WordSpecLike with Matchers with BeforeAndAfterAll with TypeCheckedTripleEquals {
val system = ActorSystem("PostSpec", JsonSerializerRegistry.actorSystemSetupFor(BasketSerializerRegistry))
override protected def afterAll() {
Await.ready(system.terminate(), 20.seconds)
}
"Basket" must {
"Add an item" in {
val driver = new PersistentEntityTestDriver(system, new BasketEntity, "Basket1")
val addItemOutcome = driver.run(AddItem(Item("Apple", 50)))
addItemOutcome.events should ===(List(ItemAdded(Item("Apple", 50))))
addItemOutcome.state.currentBasket.total should ===(50)
addItemOutcome.state.currentBasket.items should ===(IndexedSeq(Item("Apple", 50)))
addItemOutcome.replies should ===(List(Done))
addItemOutcome.issues should ===(Nil)
val getItemsOutcome = driver.run(GetBasket)
getItemsOutcome.issues should ===(Nil)
getItemsOutcome.replies should ===(List(Basket(Seq(Item("Apple", 50)), 50)))
val getPriceOutcome = driver.run(GetTotal)
getPriceOutcome.issues should ===(Nil)
getPriceOutcome.replies should ===(List(50))
}
"Clear the basket" in {
val driver = new PersistentEntityTestDriver(system, new BasketEntity, "Basket1")
val addItemOutcome = driver.run(AddItem(Item("Apple", 50)))
val clearOutcome = driver.run(ClearAll)
clearOutcome.issues should ===(Nil)
clearOutcome.replies should ===(List(Done))
val getBasketOutcome = driver.run(GetBasket)
getBasketOutcome.issues should ===(Nil)
getBasketOutcome.replies should ===(List(Basket(Seq(), 0)))
}
"Place an order" in {
val driver = new PersistentEntityTestDriver(system, new BasketEntity, "Basket2")
driver.run(AddItem(Item("Apple", 50)))
val outcome = driver.run(PlaceOrder)
outcome.issues should ===(List())
outcome.events should ===(List(OrderPlaced("Basket2", Basket(Seq(Item("Apple", 50)), 50))))
}
}
}
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:61,代码来源:BasketSpec.scala
示例4: BasketSpec
//设置package包名称以及导入依赖的类
import akka.Done
import akka.actor.ActorSystem
import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry
import com.lightbend.lagom.scaladsl.testkit.PersistentEntityTestDriver
import demo.api.basket.{Basket, Item}
import demo.impl.basket._
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import scala.concurrent.duration._
import scala.concurrent.Await
class BasketSpec extends WordSpecLike with Matchers with BeforeAndAfterAll with TypeCheckedTripleEquals {
val system = ActorSystem("PostSpec", JsonSerializerRegistry.actorSystemSetupFor(BasketSerializerRegistry))
override protected def afterAll() {
Await.ready(system.terminate(), 20.seconds)
}
"Basket" must {
"Add an item" in {
val driver = new PersistentEntityTestDriver(system, new BasketEntity, "Basket1")
val addItemOutcome = driver.run(AddItem(Item("Apple", 50)))
addItemOutcome.events should ===(List(ItemAdded(Item("Apple", 50))))
addItemOutcome.state.currentBasket.total should ===(50)
addItemOutcome.state.currentBasket.items should ===(IndexedSeq(Item("Apple", 50)))
addItemOutcome.replies should ===(List(Done))
addItemOutcome.issues should ===(Nil)
val getItemsOutcome = driver.run(GetBasket)
getItemsOutcome.issues should ===(Nil)
getItemsOutcome.replies should ===(List(Basket(Seq(Item("Apple", 50)), 50)))
val getPriceOutcome = driver.run(GetTotal)
getPriceOutcome.issues should ===(Nil)
getPriceOutcome.replies should ===(List(50))
}
}
}
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:40,代码来源:BasketSpec.scala
示例5: BasketSpec
//设置package包名称以及导入依赖的类
import akka.Done
import akka.actor.ActorSystem
import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry
import com.lightbend.lagom.scaladsl.testkit.PersistentEntityTestDriver
import demo.api.basket.{Basket, Item}
import demo.impl.basket._
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import scala.concurrent.duration._
import scala.concurrent.Await
class BasketSpec extends WordSpecLike with Matchers with BeforeAndAfterAll with TypeCheckedTripleEquals {
val system = ActorSystem("PostSpec", JsonSerializerRegistry.actorSystemSetupFor(BasketSerializerRegistry))
override protected def afterAll() {
Await.ready(system.terminate(), 20.seconds)
}
"Basket" must {
"Add an item" in {
val driver = new PersistentEntityTestDriver(system, new BasketEntity, "Basket1")
val addItemOutcome = driver.run(AddItem(Item("Apple", 50)))
addItemOutcome.events should ===(List(ItemAdded(Item("Apple", 50))))
addItemOutcome.state.currentBasket.total should ===(50)
addItemOutcome.state.currentBasket.items should ===(IndexedSeq(Item("Apple", 50)))
addItemOutcome.replies should ===(List(Done))
addItemOutcome.issues should ===(Nil)
val getItemsOutcome = driver.run(GetBasket)
getItemsOutcome.issues should ===(Nil)
getItemsOutcome.replies should ===(List(Basket(Seq(Item("Apple", 50)), 50)))
}
}
}
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:36,代码来源:BasketSpec.scala
示例6: BasketSpec
//设置package包名称以及导入依赖的类
import akka.Done
import akka.actor.ActorSystem
import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry
import com.lightbend.lagom.scaladsl.testkit.PersistentEntityTestDriver
import demo.api.basket.{Basket, Item}
import demo.impl.basket._
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import scala.concurrent.duration._
import scala.concurrent.Await
class BasketSpec extends WordSpecLike with Matchers with BeforeAndAfterAll with TypeCheckedTripleEquals {
val system = ActorSystem("PostSpec", JsonSerializerRegistry.actorSystemSetupFor(BasketSerializerRegistry))
override protected def afterAll() {
Await.ready(system.terminate(), 20.seconds)
}
"Basket" must {
"Add an item" in {
val driver = new PersistentEntityTestDriver(system, new BasketEntity, "Basket1")
val addItemOutcome = driver.run(AddItem(Item("Apple", 50)))
addItemOutcome.events should ===(List(ItemAdded(Item("Apple", 50))))
addItemOutcome.state.currentBasket.total should ===(50)
addItemOutcome.state.currentBasket.items should ===(IndexedSeq(Item("Apple", 50)))
addItemOutcome.replies should ===(List(Done))
addItemOutcome.issues should ===(Nil)
val getItemsOutcome = driver.run(GetBasket)
getItemsOutcome.issues should ===(Nil)
getItemsOutcome.replies should ===(List(Basket(Seq(Item("Apple", 50)), 50)))
val getPriceOutcome = driver.run(GetTotal)
getPriceOutcome.issues should ===(Nil)
getPriceOutcome.replies should ===(List(50))
}
"Clear the basket" in {
val driver = new PersistentEntityTestDriver(system, new BasketEntity, "Basket1")
val addItemOutcome = driver.run(AddItem(Item("Apple", 50)))
val clearOutcome = driver.run(ClearAll)
clearOutcome.issues should ===(Nil)
clearOutcome.replies should ===(List(Done))
val getBasketOutcome = driver.run(GetBasket)
getBasketOutcome.issues should ===(Nil)
getBasketOutcome.replies should ===(List(Basket(Seq(), 0)))
}
}
}
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:53,代码来源:BasketSpec.scala
示例7: Demo17Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalactic.anyvals.PosZDouble
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{LogicFunSpec, WillMatchers}
// Demo 17 - use implies with q and q
class Demo17Spec extends LogicFunSpec with WillMatchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
forAll { (x: PosZDouble) =>
val p = x will !== (PosZDouble.PositiveInfinity)
val q = squareRoot3(x).value will === (math.sqrt(x))
p implies q
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] will be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] will be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:34,代码来源:Demo17Spec.scala
示例8: Demo3Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{FunSpec, Matchers}
// DEMO 3 - use require with ensuring
class Demo3Spec extends FunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRootC function") {
it("should compute the square root") {
forAll { (x: Double) =>
whenever (x >= 0.0 && !x.isPosInfinity) {
noException should be thrownBy { squareRootC(x) }
}
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] should be thrownBy {
squareRootC(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] should be thrownBy {
squareRootC(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:33,代码来源:Demo3Spec.scala
示例9: Demo5Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{FunSpec, Matchers}
// DEMO 5 - using a ForAll
class Demo5Spec extends FunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
forAll { (x: Double) =>
whenever(x >= 0.0 && !x.isPosInfinity) {
squareRoot1(x) should === (math.sqrt(x))
}
}
}
it("should compute the square root and check with tolerance") {
forAll { (x: Double) =>
whenever (x >= 0.0 && !x.isPosInfinity) {
val result = squareRoot1(x)
val tolerance = math.ulp(x)
result * result should === (x +- tolerance)
}
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:39,代码来源:Demo5Spec.scala
示例10: Demo13Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalactic.anyvals.PosZDouble
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{LogicFunSpec, Matchers}
// (Demo 12 PosInt.ensuringValid in the REPL)
// DEMO 13 - Use PosZDouble as result type
class Demo13Spec extends LogicFunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
forAll { (x: PosZDouble) =>
whenever (!x.isPosInfinity) {
squareRoot3(x).value should === (math.sqrt(x))
}
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:36,代码来源:Demo13Spec.scala
示例11: Demo16Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalactic.anyvals.PosZDouble
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{LogicFunSpec, WillMatchers}
// DEMO 16 use implies
class Demo16Spec extends LogicFunSpec with WillMatchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
forAll { (x: PosZDouble) =>
(x will !== (PosZDouble.PositiveInfinity)) implies {
squareRoot3(x).value will === (math.sqrt(x))
}
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] will be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] will be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:34,代码来源:Demo16Spec.scala
示例12: Demo15Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalactic.anyvals.PosZDouble
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{LogicFunSpec, Matchers, WillMatchers}
// (Demo 14 was REPL will and expect)
// DEMO 15 use Expectations with whenever
class Demo15Spec extends LogicFunSpec with WillMatchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
forAll { (x: PosZDouble) =>
whenever (!x.isPosInfinity) {
squareRoot3(x).value will === (math.sqrt(x))
}
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] will be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] will be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:36,代码来源:Demo15Spec.scala
示例13: Demo1Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{FunSpec, Matchers}
// DEMO 1 - use assume with an ensuring that uses ULP and a tolerance
class Demo1Spec extends FunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRootA function") {
it("should compute the square root") {
forAll { (x: Double) =>
whenever (x >= 0.0 && !x.isPosInfinity) {
noException should be thrownBy { squareRootA(x) }
}
}
}
it("should should throw IAE on negative input") {
an [AssertionError] should be thrownBy {
squareRootA(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [AssertionError] should be thrownBy {
squareRootA(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:33,代码来源:Demo1Spec.scala
示例14: Demo18Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalactic.anyvals.PosZDouble
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{Expectation, Fact, LogicFunSpec, WillMatchers}
// Demo 18 - use implies with Booleans
class Demo18Spec extends LogicFunSpec with WillMatchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
forAll { (x: PosZDouble) =>
x != PosZDouble.PositiveInfinity implies squareRoot3(x).value == math.sqrt(x)
}
}
it("should compute the square root (version 2)") {
forAll { (x: PosZDouble) =>
val p: Fact = x != PosZDouble.PositiveInfinity
val q: Fact = squareRoot3(x).value == math.sqrt(x)
p implies q
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] will be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] will be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:39,代码来源:Demo18Spec.scala
示例15: Demo9Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{LogicFunSpec, Matchers}
// DEMO 9 - Our forAll in a LogicSpec
class Demo9Spec extends LogicFunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
forAll { (x: Double) =>
whenever (x >= 0.0 && !x.isPosInfinity) {
squareRoot1(x) should === (math.sqrt(x))
}
}
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:33,代码来源:Demo9Spec.scala
示例16: Demo7Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import java.io.{File, FileWriter}
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
import org.scalatest.{FunSpec, Matchers}
// (Demo 6 was REPL demo of Assertion and Succeeded)
// DEMO 7 File output
class Demo7Spec extends FunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
val two = squareRoot1(4.0)
val outputFile = new FileWriter("squareRoot.out")
try outputFile.write(two.toString + "\n")
finally outputFile.close()
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:36,代码来源:Demo7Spec.scala
示例17: Demo4Spec
//设置package包名称以及导入依赖的类
package org.scalatest.examples
// Type-constructor polymorphism
import org.scalactic.TypeCheckedTripleEquals
import org.scalactic.anyvals.PosZDouble
import org.scalatest.{FunSpec, LogicFunSpec, Matchers, WillMatchers}
import org.scalatest.examples.Demo._
import org.scalatest.prop.PropertyChecks
// DEMO 4 - an example based test
class Demo4Spec extends FunSpec with Matchers with PropertyChecks with TypeCheckedTripleEquals {
describe("The squareRoot1 function") {
it("should compute the square root") {
val one = squareRoot1(1.0)
one shouldEqual 1.0
val two = squareRoot1(4.0)
two shouldEqual 2.0
val three = squareRoot1(9.0)
three shouldEqual 3.0
}
it("should should throw IAE on negative input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(-1.0)
}
}
it("should should throw IAE on positive infinity input") {
an [IllegalArgumentException] should be thrownBy {
squareRoot1(Double.PositiveInfinity)
}
}
}
}
开发者ID:bvenners,项目名称:scalaX2016Demos,代码行数:35,代码来源:Demo4Spec.scala
示例18: ValidatedOps
//设置package包名称以及导入依赖的类
package freecli
package testkit
import cats.data.Validated
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.{FunSpec, Matchers}
trait Test extends FunSpec with Matchers with TypeCheckedTripleEquals {
implicit class ValidatedOps[A, B](v: Validated[A, B]) {
def invalid: A = v match {
case [email protected](_) =>
throw new IllegalArgumentException(
s"Tried to access invalid but was valid $valid")
case Validated.Invalid(a) => a
}
def valid: B = v match {
case [email protected](_) =>
throw new IllegalArgumentException(
s"Tried to access valid but was invalid $invalid")
case Validated.Valid(b) => b
}
}
}
开发者ID:pavlosgi,项目名称:freecli,代码行数:27,代码来源:Test.scala
示例19: CeilTest
//设置package包名称以及导入依赖的类
package org.hammerlab.math
import org.hammerlab.test.Suite
import org.scalactic.TypeCheckedTripleEquals
class CeilTest
extends Suite
with TypeCheckedTripleEquals {
test("ints") {
ceil( 0, 20) should ===(0)
ceil(10, 20) should ===(1)
ceil(19, 20) should ===(1)
ceil(20, 20) should ===(1)
ceil(21, 20) should ===(2)
}
test("longs") {
ceil( 0L, 20L) should ===(0)
ceil(10L, 20L) should ===(1L)
ceil(19L, 20L) should ===(1L)
ceil(20L, 20L) should ===(1L)
ceil(21L, 20L) should ===(2L)
ceil(1L << 40, 1 << 4) should be(1L << 36)
ceil(1L << 40, 1L << 36) should be(1 << 4)
}
}
开发者ID:hammerlab,项目名称:math-utils,代码行数:29,代码来源:CeilTest.scala
示例20: shouldFindPokerGame
//设置package包名称以及导入依赖的类
package com.lambtors.poker_api.module.poker.behaviour
import scala.concurrent.Future
import com.lambtors.poker_api.module.poker.domain.PokerGameRepository
import com.lambtors.poker_api.module.poker.domain.model.{GameId, PokerGame}
import org.scalactic.TypeCheckedTripleEquals
import org.scalamock.scalatest.MockFactory
import org.scalatest.{Matchers, OneInstancePerTest, WordSpec}
import org.scalatest.concurrent.ScalaFutures
trait PokerBehaviourSpec
extends WordSpec
with Matchers
with TypeCheckedTripleEquals
with MockFactory
with OneInstancePerTest
with ScalaFutures
with MockedPokerGameRepository
trait MockedPokerGameRepository extends MockFactory {
protected val pokerGameRepository: PokerGameRepository = mock[PokerGameRepository]
def shouldFindPokerGame(gameId: GameId, pokerGame: PokerGame): Unit =
(pokerGameRepository.search _).expects(gameId).once().returning(Future.successful(Some(pokerGame)))
def shouldNotFindPokerGame(gameId: GameId): Unit =
(pokerGameRepository.search _).expects(gameId).once().returning(Future.successful(None))
def shouldInsertPokerGame(pokerGame: PokerGame): Unit =
(pokerGameRepository.insert _).expects(pokerGame).once().returning(Future.successful(Unit))
}
开发者ID:lambtors,项目名称:poker-api,代码行数:33,代码来源:PokerBehaviourSpec.scala
注:本文中的org.scalactic.TypeCheckedTripleEquals类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论