Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 27, 2023 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/0804e5a3dac66fdafcfca0061beab76f to your computer and use it in GitHub Desktop.
Save dacr/0804e5a3dac66fdafcfca0061beab76f to your computer and use it in GitHub Desktop.
lambdas variations in scala / published by https://github.com/dacr/code-examples-manager #4664cc4a-aa71-430c-ab64-76f33effa7b5/382d8115dd34f822d2e58cf46decf8028850988a
// summary : lambdas variations in scala
// keywords : scala, language-feature, fold, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : 4664cc4a-aa71-430c-ab64-76f33effa7b5
// created-on : 2021-10-16T10:54:03+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.3.0"
//> using dep "org.scalatest::scalatest:3.2.16"
//> using objectWrapper
// ---------------------
import org.scalatest._, flatspec._, matchers._, OptionValues._
class ThatSpec extends AnyFlatSpec with should.Matchers {
override def suiteName = "ThatSpec"
"identify function" should "do nothing" in {
Some(true).map(identity) shouldBe Some(true)
Some(false).map(identity) shouldBe Some(false)
}
"magic function placeholder" should "be usable in many situations" in {
Some(true).filter(if (_) false else true) shouldBe None
}
}
org.scalatest.tools.Runner.main(Array("-oDF", "-s", classOf[ThatSpec].getName))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment