当前位置: 首页>>代码示例>>Scala>>正文


Scala illTyped类代码示例

本文整理汇总了Scala中shapeless.test.illTyped的典型用法代码示例。如果您正苦于以下问题:Scala illTyped类的具体用法?Scala illTyped怎么用?Scala illTyped使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了illTyped类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: NegateSpec

//设置package包名称以及导入依赖的类
package singleton.ops

import org.scalacheck.Properties
import singleton.TestUtils._
import shapeless.test.illTyped

class NegateSpec extends Properties("Negate") {
  property("Nat argument") = wellTyped {
    implicitly[Require[Negate[shapeless.Nat._1] == (-1)]]
  }

  property("Char argument") = wellTyped {
    implicitly[Require[Negate['T'] == (-84)]]
  }

  property("Int argument") = wellTyped {
    implicitly[Require[Negate[2] == (-2)]]
    implicitly[Require[Negate[-2] == 2]]
  }

  property("Long argument") = wellTyped {
    implicitly[Require[Negate[5L] == (-5L)]]
    implicitly[Require[Negate[-5L] == 5L]]
  }

  property("Float argument") = wellTyped {
    implicitly[Require[Negate[1.5f] == (-1.5f)]]
    implicitly[Require[Negate[-1.5f] == 1.5f]]
  }

  property("Double argument") = wellTyped {
    implicitly[Require[Negate[1.5] == (-1.5)]]
    implicitly[Require[Negate[-1.5] == 1.5]]
  }

  property("Boolean argument") = {
    illTyped("""implicitly[Negate[true]]""")
    true
  }

  property("String argument") = {
    illTyped("""implicitly[Negate["Something"]]""")
    true
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:46,代码来源:NegateSpec.scala

示例2: LessThanSpec

//设置package包名称以及导入依赖的类
package singleton.ops

import org.scalacheck.Properties
import shapeless.test.illTyped
import singleton.TestUtils._

class LessThanSpec extends Properties("LessThan") {
  property("3.5F < 3.6F") = wellTyped {
    def require[P1 <: XDouble, P2 <: XDouble](implicit op : Require[P1 < P2]) : op.Out{} = op.value
    val r = require[3.5, 3.6]
  }

  property("!(5 < 4)") = wellTyped {
    def require[P1 <: XDouble, P2 <: XDouble](implicit op : Require[P1 < P2]) : op.Out{} = op.value
    illTyped(""" val r = require[3.6, 3.5] """)
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:18,代码来源:LessThanSpec.scala

示例3: CheckedLongSpec

//设置package包名称以及导入依赖的类
package singleton.twoface

import org.scalacheck.Properties
import shapeless.test.illTyped
import singleton.TestUtils._
import singleton.ops._

class CheckedLongSpec extends Properties("Checked.Long") {
  type CondSmallerThan50[T, P] = T < P
  type MsgSmallerThan50[T, P] = "Failed Check"
  type Param50 = 50L
  type CheckedSmallerThan50[T] = Checked.Long[T, CondSmallerThan50, Param50, MsgSmallerThan50]

  implicit object RuntimeChecked extends Checked.Runtime[Long, Long, CondSmallerThan50, MsgSmallerThan50] {
    def cond(l : Long, p : Option[Long]) : scala.Boolean = l < 50L
    def msg(l : Long, p : Option[Long]) : java.lang.String = s"Failed Check"
  }

  def smallerThan50[T](t : CheckedSmallerThan50[T]) : Unit = {t.unsafeCheck()}

  property("Compile-time checks") = wellTyped {
    smallerThan50(40L)
    smallerThan50(TwoFace.Long(40L))
    illTyped("""smallerThan50(50L)""")
    illTyped("""smallerThan50(TwoFace.Long(50L))""")
  }

  property("Run-time checks") = wellTyped {
    smallerThan50(us(40L))
    smallerThan50(TwoFace.Long(us(40L)))
    illRun{smallerThan50(us(50L))}
    illRun{smallerThan50(TwoFace.Long(us(50L)))}
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:35,代码来源:CheckedLongSpec.scala

示例4: CheckedStringSpec

//设置package包名称以及导入依赖的类
package singleton.twoface

import org.scalacheck.Properties
import shapeless.test.illTyped
import singleton.TestUtils._
import singleton.ops._

class CheckedStringSpec extends Properties("Checked.String") {
  type CondCheckedLengthSmallerThan5[T, P] = Length[T] < P
  type MsgCheckedLengthSmallerThan5[T, P] = "Failed Check"
  type Param = 5
  type CheckedLengthSmallerThan5[T] = Checked.String[T, CondCheckedLengthSmallerThan5, Param, MsgCheckedLengthSmallerThan5]

  implicit object RuntimeChecked extends Checked.Runtime[String, Int, CondCheckedLengthSmallerThan5, MsgCheckedLengthSmallerThan5] {
    def cond(l : String, p : Option[Int]) : scala.Boolean = l.length < 5
    def msg(l : String, p : Option[Int]) : java.lang.String = s"Failed Check"
  }

  def lengthSmallerThan5[T](t : CheckedLengthSmallerThan5[T]) : Unit = {t.unsafeCheck()}

  property("Compile-time checks") = wellTyped {
    lengthSmallerThan5("Hi")
    lengthSmallerThan5(TwoFace.String("Hi"))
    illTyped("""smallerThan50("Hello")""")
    illTyped("""smallerThan50(TwoFace.String("Hello"))""")
  }

  property("Run-time checks") = wellTyped {
    lengthSmallerThan5(us("Hi"))
    lengthSmallerThan5(TwoFace.String(us("Hi")))
    illRun{lengthSmallerThan5(us("Hello"))}
    illRun{lengthSmallerThan5(TwoFace.String(us("Hello")))}
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:35,代码来源:CheckedStringSpec.scala

示例5: CheckedIntSpec

//设置package包名称以及导入依赖的类
package singleton.twoface

import org.scalacheck.Properties
import shapeless.test.illTyped
import singleton.TestUtils._
import singleton.ops._

class CheckedIntSpec extends Properties("Checked.Int") {
  class FixedSizeVector[L] private (val length : TwoFace.Int[L]) {
    def concat[L2](that : FixedSizeVector[L2]) = FixedSizeVector.protCreate(this.length + that.length)
    override def toString = s"FixedSizeVector($length)"
    def pretty(implicit rt: RunTime[L]) = if (rt) s"FixedSizeVector($length)" else s"FixedSizeVector[$length]"
  }

  object FixedSizeVector {
    //Defining Checked Length Type
    protected type CondCheckedLength[L, P] = L > 0
    protected type ParamCheckedLength = 0
    protected type MsgCheckedLength[L, P] = "Length must be positive (received value of " + ToString[L] + ")"
    type CheckedLength[L] = Checked.Int[L, CondCheckedLength, ParamCheckedLength, MsgCheckedLength]

    implicit object RuntimeCheckedLength extends Checked.Runtime[Int, Int, CondCheckedLength, MsgCheckedLength] {
      def cond(l : Int, p : Option[Int]) : scala.Boolean = l > 0
      def msg(l : Int, p : Option[Int]) : java.lang.String = s"Length must be positive (received value of $l)"
    }

    //Protected Constructor (performs unsafe run-time check, if compile-time check is not possible)
    protected def protCreate[L](tfLength : TwoFace.Int[L]) : FixedSizeVector[L] =
      new FixedSizeVector[L](tfLength)

    //Public Constructors (perform compile-time check, if possible)
    def apply[L](checkedLength : CheckedLength[L]) =
      protCreate(checkedLength.unsafeCheck())
    implicit def apply[L](implicit checkedLength : CheckedLength[L], di : DummyImplicit) =
      protCreate(checkedLength.unsafeCheck())
  }

  property("Compile-time checks") = wellTyped {
    val ctv5 : FixedSizeVector[5] = FixedSizeVector[5]
    val ctv2 : FixedSizeVector[2] = FixedSizeVector(2)
    val ctv7 : FixedSizeVector[7] = implicitly[FixedSizeVector[7]]
    val ctv9 : FixedSizeVector[9] = ctv2 concat ctv7
    illTyped("""FixedSizeVector(0)""")
  }

  property("Run-time checks") = wellTyped {
    val ctv2 = FixedSizeVector(2)
    val rtv2 = FixedSizeVector(us(2))
    val rtv4 = rtv2 concat rtv2 //runtime concat runtime => runtime
    val rtv6 = rtv4 concat ctv2 //runtime concat compile-time => runtime
    illRun{FixedSizeVector(us(0))}
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:54,代码来源:CheckedIntSpec.scala

示例6: CheckedDoubleSpec

//设置package包名称以及导入依赖的类
package singleton.twoface

import org.scalacheck.Properties
import shapeless.test.illTyped
import singleton.TestUtils._
import singleton.ops._

class CheckedDoubleSpec extends Properties("Checked.Double") {
  type CondSmallerThan50[T, P] = T < P
  type MsgSmallerThan50[T, P] = "Failed Check"
  type Param50 = 50.0
  type CheckedSmallerThan50[T] = Checked.Double[T, CondSmallerThan50, Param50, MsgSmallerThan50]

  implicit object RuntimeChecked extends Checked.Runtime[Double, Double, CondSmallerThan50, MsgSmallerThan50] {
    def cond(l : Double, p : Option[Double]) : scala.Boolean = l < 50.0
    def msg(l : Double, p : Option[Double]) : java.lang.String = s"Failed Check"
  }

  def smallerThan50[T](t : CheckedSmallerThan50[T]) : Unit = {t.unsafeCheck()}

  property("Compile-time checks") = wellTyped {
    smallerThan50(40.0)
    smallerThan50(TwoFace.Double(40.0))
    illTyped("""smallerThan50(50.0)""")
    illTyped("""smallerThan50(TwoFace.Double(50.0))""")
  }

  property("Run-time checks") = wellTyped {
    smallerThan50(us(40.0))
    smallerThan50(TwoFace.Double(us(40.0)))
    illRun{smallerThan50(us(50.0))}
    illRun{smallerThan50(TwoFace.Double(us(50.0)))}
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:35,代码来源:CheckedDoubleSpec.scala

示例7: CheckedFloatSpec

//设置package包名称以及导入依赖的类
package singleton.twoface

import org.scalacheck.Properties
import shapeless.test.illTyped
import singleton.TestUtils._
import singleton.ops._

class CheckedFloatSpec extends Properties("Checked.Float") {
  type CondSmallerThan50[T, P] = T < P
  type MsgSmallerThan50[T, P] = "Failed Check"
  type Param50 = 50.0f
  type CheckedSmallerThan50[T] = Checked.Float[T, CondSmallerThan50, Param50, MsgSmallerThan50]

  implicit object RuntimeChecked extends Checked.Runtime[Float, Float, CondSmallerThan50, MsgSmallerThan50] {
    def cond(l : Float, p : Option[Float]) : scala.Boolean = l < 50.0f
    def msg(l : Float, p : Option[Float]) : java.lang.String = s"Failed Check"
  }

  def smallerThan50[T](t : CheckedSmallerThan50[T]) : Unit = {t.unsafeCheck()}

  property("Compile-time checks") = wellTyped {
    smallerThan50(40.0f)
    smallerThan50(TwoFace.Float(40.0f))
    illTyped("""smallerThan50(50.0f)""")
    illTyped("""smallerThan50(TwoFace.Float(50.0f))""")
  }

  property("Run-time checks") = wellTyped {
    smallerThan50(us(40.0f))
    smallerThan50(TwoFace.Float(us(40.0f)))
    illRun{smallerThan50(us(50.0f))}
    illRun{smallerThan50(TwoFace.Float(us(50.0f)))}
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:35,代码来源:CheckedFloatSpec.scala

示例8: CheckedCharSpec

//设置package包名称以及导入依赖的类
package singleton.twoface

import org.scalacheck.Properties
import shapeless.test.illTyped
import singleton.TestUtils._
import singleton.ops._

class CheckedCharSpec extends Properties("Checked.Char") {
  type CondSmallerThan50[T, P] = T < P
  type MsgSmallerThan50[T, P] = "Failed Check"
  type Param50 = '\u0032'
  type CheckedSmallerThan50[T] = Checked.Char[T, CondSmallerThan50, Param50, MsgSmallerThan50]

  implicit object RuntimeChecked extends Checked.Runtime[Char, Char, CondSmallerThan50, MsgSmallerThan50] {
    def cond(l : Char, p : Option[Char]) : scala.Boolean = l < '\u0032'
    def msg(l : Char, p : Option[Char]) : java.lang.String = s"Failed Check"
  }

  def smallerThan50[T](t : CheckedSmallerThan50[T]) : Unit = {t.unsafeCheck()}

  property("Compile-time checks") = wellTyped {
    smallerThan50('\u0020')
    smallerThan50(TwoFace.Char('\u0020'))
    illTyped("""smallerThan50('\u0032')""")
    illTyped("""smallerThan50(TwoFace.Char('\u0032'))""")
  }

  property("Run-time checks") = wellTyped {
    smallerThan50(us('\u0020'))
    smallerThan50(TwoFace.Char(us('\u0020')))
    illRun{smallerThan50(us('\u0032'))}
    illRun{smallerThan50(TwoFace.Char(us('\u0032')))}
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:35,代码来源:CheckedCharSpec.scala

示例9: CheckedBooleanSpec

//设置package包名称以及导入依赖的类
package singleton.twoface

import org.scalacheck.Properties
import shapeless.test.illTyped
import singleton.TestUtils._
import singleton.ops._

class CheckedBooleanSpec extends Properties("Checked.Boolean") {
  type CondTrue[T, P] = T == P
  type MsgTrue[T, P] = "Failed Check"
  type Param = true
  type CheckedTrue[T] = Checked.Boolean[T, CondTrue, Param, MsgTrue]

  implicit object RuntimeChecked extends Checked.Runtime[Boolean, Boolean, CondTrue, MsgTrue] {
    def cond(l : Boolean, p : Option[Boolean]) : scala.Boolean = l
    def msg(l : Boolean, p : Option[Boolean]) : java.lang.String = s"Failed Check"
  }

  def condTrue[T](t : CheckedTrue[T]) : Unit = {t.unsafeCheck()}

  property("Compile-time checks") = wellTyped {
    condTrue(true)
    condTrue(TwoFace.Boolean(true))
    illTyped("""smallerThan50(false)""")
    illTyped("""smallerThan50(TwoFace.Boolean(false))""")
  }

  property("Run-time checks") = wellTyped {
    condTrue(us(true))
    condTrue(TwoFace.Boolean(us(true)))
    illRun{condTrue(us(false))}
    illRun{condTrue(TwoFace.Boolean(us(false)))}
  }
} 
开发者ID:fthomas,项目名称:singleton-ops,代码行数:35,代码来源:CheckedBooleanSpec.scala

示例10: CommandsResultsSyntaxSpec

//设置package包名称以及导入依赖的类
package ru.pavkin.todoist.api.core.model

import java.util.UUID

import org.scalatest.prop.Checkers
import org.scalatest.{FunSuite, Matchers}
import ru.pavkin.todoist.api.core.model.util.{ReversedAtSyntax, CommandResultHList, CombineCommands}
import shapeless.HNil
import shapeless.test.{typed, illTyped}

class CommandsResultsSyntaxSpec extends FunSuite
  with Matchers
  with Checkers
  with CommandResultHList.Syntax
  with ReversedAtSyntax {

  def id = UUID.randomUUID()

  val success = CommandResult(id, CommandSuccess)
  val failure = CommandResult(id, CommandFailure(1, "error"))
  val tempIdSuccess = TempIdCommandResult(id, TempIdSuccess(id, 666))
  val tempIdFailure = TempIdCommandResult(id, TempIdFailure(2, "error"))
  val multiSuccess = CommandResult(id, MultiItemCommandStatus(Map(1 -> CommandSuccess, 2 -> CommandSuccess)))
  val partialFailure = CommandResult(
    id, MultiItemCommandStatus(Map(1 -> CommandFailure(1, "error"), 2 -> CommandSuccess))
  )

  test("Typesafe resultFor should get the command under reversed index") {
    val result = success :: tempIdFailure :: HNil
    result.resultFor(_0) shouldBe tempIdFailure
    typed[TempIdCommandResult](result.resultFor(_0))
    result.resultFor(_1) shouldBe success
    typed[CommandResult](result.resultFor(_1))
    illTyped("""result.resultFor(_2)""")
  }

  test("Runtime resultFor should get the command with uuid") {
    val result = success :: tempIdFailure :: HNil
    result.resultFor(success.uuid) shouldBe Some(success)
    typed[Option[TodoistCommandResult]](result.resultFor(success.uuid))
    result.resultFor(tempIdFailure.uuid) shouldBe Some(tempIdFailure)
    result.resultFor(failure.uuid) shouldBe None
  }

  test("single command result isSuccess is true only in case of success") {
    success.isSuccess shouldBe true
    tempIdSuccess.isSuccess shouldBe true
    multiSuccess.isSuccess shouldBe true
    failure.isSuccess shouldBe false
    tempIdFailure.isSuccess shouldBe false
    partialFailure.isSuccess shouldBe false
  }

  test("Multiple results are success if all commands succeed") {
    (success :: tempIdSuccess :: multiSuccess :: HNil).isSuccess shouldBe true
    (success :: tempIdSuccess :: failure :: HNil).isSuccess shouldBe false
    (partialFailure :: success :: HNil).isSuccess shouldBe false
  }
} 
开发者ID:vpavkin,项目名称:scalist,代码行数:60,代码来源:CommandsResultsSyntaxSpec.scala

示例11: CombineCommandsSyntaxSpec

//设置package包名称以及导入依赖的类
package ru.pavkin.todoist.api.core.model

import java.util.UUID

import org.scalacheck.Arbitrary
import org.scalatest.prop.Checkers
import org.scalatest.{FunSuite, Matchers}
import ru.pavkin.todoist.api.core.model.util.CombineCommands
import ru.pavkin.todoist.api.core.tags.syntax._
import shapeless.HNil
import shapeless.test.illTyped

class CombineCommandsSyntaxSpec extends FunSuite with Matchers with Checkers with CombineCommands.Syntax {

  implicit val gen = Arbitrary(org.scalacheck.Gen.uuid)

  val c1 = AddProject("Project")
  val c2 = AddLabel("Label")
  val c3 = AddTask("Task", 1.projectId)

  test("Commands combine in HList") {
    c1 :+ c2 shouldBe c1 :: c2 :: HNil
  }

  test("HList :+ works with combined commands") {
    c1 :+ c2 :+ c3 shouldBe c1 :: c2 :: c3 :: HNil
  }

  test("forIt creates temp_id dependant command") {
    val uuid = UUID.randomUUID
    val tempId = UUID.randomUUID
    c1.forIt(AddTask("task", _, uuid = uuid, tempId = tempId.taskId)) shouldBe
      AddTask[UUID]("task", c1.tempId, uuid = uuid, tempId = tempId.taskId)
  }

  test("andForIt creates temp_id dependant command and adds it to the parent") {
    check { (uuid: UUID, tempId: UUID) =>
      c1.andForIt(AddTask("task", _, uuid = uuid, tempId = tempId.taskId)) ==
        (c1 :: AddTask[UUID]("task", c1.tempId, uuid = uuid, tempId = tempId.taskId) :: HNil)
    }
  }

  test("andForItAll creates temp_id dependant commands and adds them to the parent") {
    check { (uuid1: UUID, tempId1: UUID, uuid2: UUID, tempId2: UUID) =>
      c1.andForItAll(id =>
        AddTask("task", id, uuid = uuid1, tempId = tempId1.taskId) :+
          AddTask("task2", id, uuid = uuid2, tempId = tempId2.taskId)
      ) ==
        (c1 ::
          AddTask[UUID]("task", c1.tempId, uuid = uuid1, tempId = tempId1.taskId) ::
          AddTask[UUID]("task2", c1.tempId, uuid = uuid2, tempId = tempId2.taskId) ::
          HNil)
    }
  }

  test("Only Commands combine") {
    illTyped("""12 :+ 13""")
    illTyped(""" true :+ 2 """)
  }
} 
开发者ID:vpavkin,项目名称:scalist,代码行数:61,代码来源:CombineCommandsSyntaxSpec.scala

示例12: TagsSyntaxSpec

//设置package包名称以及导入依赖的类
package ru.pavkin.todoist.api.core.model

import java.util.UUID

import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.Gen
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalatest.{FunSuite, Matchers}
import ru.pavkin.todoist.api.core.tags
import ru.pavkin.todoist.api.core.tags._
import shapeless.tag
import shapeless.test.illTyped

class TagsSyntaxSpec extends FunSuite
  with Matchers
  with GeneratorDrivenPropertyChecks
  with tags.Syntax {

  test("tags conversions work for resource ids") {
    forAll(arbitrary[Int]) { (i: Int) =>
      i.projectId shouldBe tag[ProjectId](i)
      i.labelId shouldBe tag[LabelId](i)
      i.userId shouldBe tag[UserId](i)
      i.taskId shouldBe tag[TaskId](i)
    }
    forAll(Gen.uuid) { (i: UUID) =>
      i.projectId shouldBe tag[ProjectId](i)
      i.labelId shouldBe tag[LabelId](i)
      i.userId shouldBe tag[UserId](i)
      i.taskId shouldBe tag[TaskId](i)
    }
  }

  test("tags conversions don't work for other types") {
    illTyped(""" "a".projectId """)
    illTyped(""" "a".labelId """)
    illTyped(""" true.taskId """)
    illTyped(""" 100L.userId""")
  }
} 
开发者ID:vpavkin,项目名称:scalist,代码行数:41,代码来源:TagsSyntaxSpec.scala

示例13: HasRawRequestSpec

//设置package包名称以及导入依赖的类
package ru.pavkin.todoist.api.core

import org.scalacheck.Gen
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import shapeless.test.illTyped
import shapeless.{::, HNil}

class HasRawRequestSpec extends FunSuite with Matchers with GeneratorDrivenPropertyChecks {

  test("HasRawRequest") {
    implicit val i1 = HasRawRequest.resource[Int](List("Int"))
    implicit val i2 = HasRawRequest.resource[String](List("String"))

    HasRawRequest[Int]
    HasRawRequest[String]
    HasRawRequest[Int :: String :: HNil].rawRequest shouldBe Map("resource_types" -> List("\"Int\"", "\"String\""))

    illTyped("""HasRawRequest[Boolean]""")
    illTyped("""HasRawRequest[Boolean :: Int :: HNil]""")
    illTyped("""HasRawRequest[Int :: Boolean :: HNil]""")
  }

  implicit val strGen: Gen[String] = Gen.alphaStr

  test("HasRawRequest combinates") {
    forAll((k: String, v1: String, v2: String) => {
      implicit val i1 = HasRawRequest[Int](Map(k -> List(v1)))
      implicit val i2 = HasRawRequest[String](Map(k -> List(v2)))
      HasRawRequest[Int :: String :: HNil].rawRequest shouldEqual Map(k -> List(v1, v2))
    })
  }
} 
开发者ID:vpavkin,项目名称:scalist,代码行数:34,代码来源:HasRawRequestSpec.scala

示例14: HasCommandTypeSpec

//设置package包名称以及导入依赖的类
package ru.pavkin.todoist.api.core

import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalatest.{FunSuite, Matchers}
import ru.pavkin.todoist.api.core.HasCommandType.syntax._
import ru.pavkin.todoist.api.core.model.LocationBasedReminder.TriggerKind
import ru.pavkin.todoist.api.core.model._
import ru.pavkin.todoist.api.core.tags.syntax._
import shapeless.test.illTyped

class HasCommandTypeSpec extends FunSuite with Matchers with GeneratorDrivenPropertyChecks {

  test("Valid commands have types") {
    AddProject("1").commandType shouldBe "project_add"
    AddLabel("1").commandType shouldBe "label_add"
    AddTask[Int]("1", 1.projectId).commandType shouldBe "item_add"
    AddTaskToInbox("1").commandType shouldBe "item_add"
    AddFilter("1", "1").commandType shouldBe "filter_add"
    AddNote[Int]("1", 1.taskId).commandType shouldBe "note_add"
    AddRelativeTimeBasedReminder[Int](
      1.taskId,
      ReminderService.Push,
      ReminderPeriod.min30
    ).commandType shouldBe "reminder_add"
    AddLocationBasedReminder[Int](
      1.taskId,
      "1",
      1.0,
      1.0,
      TriggerKind.Enter,
      100
    ).commandType shouldBe "reminder_add"
    UpdateProject[Int](1.projectId).commandType shouldBe "project_update"
    UpdateLabel[Int](1.labelId).commandType shouldBe "label_update"
    UpdateTask[Int](1.taskId).commandType shouldBe "item_update"
    UpdateFilter[Int](1.filterId).commandType shouldBe "filter_update"
    UpdateNote[Int](1.noteId).commandType shouldBe "note_update"

    DeleteProjects[Int](List(1.projectId)).commandType shouldBe "project_delete"
    DeleteTasks[Int](List(1.taskId)).commandType shouldBe "item_delete"
    DeleteLabel[Int](1.labelId).commandType shouldBe "label_delete"
    DeleteNote[Int](1.noteId).commandType shouldBe "note_delete"
    DeleteFilter[Int](1.filterId).commandType shouldBe "filter_delete"
    DeleteReminder[Int](1.reminderId).commandType shouldBe "reminder_delete"

    CloseTask[Int](1.taskId).commandType shouldBe "item_close"
    MoveTasks(Map.empty, 1.projectId).commandType shouldBe "item_move"
    UncompleteTasks[Int](List(1.taskId)).commandType shouldBe "item_uncomplete"
    ArchiveProjects[Int](List(1.projectId)).commandType shouldBe "project_archive"
    UnarchiveProjects[Int](List(1.projectId)).commandType shouldBe "project_unarchive"
  }

  test("Other types don't have commandType") {
    illTyped("""1.commandType""")
  }
} 
开发者ID:vpavkin,项目名称:scalist,代码行数:57,代码来源:HasCommandTypeSpec.scala

示例15: ToRawRequestSpec

//设置package包名称以及导入依赖的类
package ru.pavkin.todoist.api.core

import org.scalacheck.Gen.alphaStr
import org.scalacheck.Gen.posNum
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import shapeless.test.illTyped
import shapeless.{::, HNil}

class ToRawRequestSpec extends FunSuite with Matchers with GeneratorDrivenPropertyChecks {

  implicit val i1 = ToRawRequest.command[Int]((i: Int) => List(i.toString))
  implicit val i2 = ToRawRequest.command[String]((s: String) => List(s))

  test("ToRawRequest") {

    ToRawRequest[Int]
    ToRawRequest[String]
    ToRawRequest[Int :: String :: HNil].rawRequest(2 :: "abc" :: HNil) shouldBe
      Map("commands" -> List("2", "abc"))

    illTyped("""ToRawRequest[Boolean]""")
    illTyped("""ToRawRequest[Boolean :: Int :: HNil]""")
    illTyped("""ToRawRequest[Int :: Boolean :: HNil]""")
  }

  test("ToRawRequest combinates") {
    forAll(posNum[Int], alphaStr) { (a: Int, b: String) =>
      ToRawRequest[Int :: String :: HNil].rawRequest(a :: b :: HNil) shouldEqual
        Map(ToRawRequest.COMMANDS -> List(a.toString, b))
    }
  }
} 
开发者ID:vpavkin,项目名称:scalist,代码行数:34,代码来源:ToRawRequestSpec.scala


注:本文中的shapeless.test.illTyped类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。