本文整理汇总了Scala中org.scalactic.TypeCheckedTripleEquals类的典型用法代码示例。如果您正苦于以下问题:Scala TypeCheckedTripleEquals类的具体用法?Scala TypeCheckedTripleEquals怎么用?Scala TypeCheckedTripleEquals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeCheckedTripleEquals类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
}
}
}
示例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)
}
}
}
}
示例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))))
}
}
}
示例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))
}
}
}
示例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)))
}
}
}
示例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)))
}
}
}
示例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)
}
}
}
}
示例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)
}
}
}
}
示例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)
}
}
}
}
示例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)
}
}
}
}
示例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)
}
}
}
}
示例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)
}
}
}
}
示例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)
}
}
}
}
示例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)
}
}
}
}
示例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)
}
}
}
}