Last active
May 25, 2024 10:18
-
-
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/f808b85b3b4f129aa514afd96134d2c9364c1cb9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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.4.2" | |
//> 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