Created
November 23, 2015 16:25
-
-
Save ghik/5dc2ff9dee888960842c to your computer and use it in GitHub Desktop.
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
| package com.avsystem.commons | |
| package misc | |
| import org.scalatest.FunSuite | |
| /** | |
| * Author: ghik | |
| * Created: 23/11/15. | |
| */ | |
| class SamTest extends FunSuite { | |
| trait NoArgSam { | |
| def handle(): String | |
| } | |
| object NoArgSam extends SamCompanion[NoArgSam, () => String] | |
| trait SingleArgSam { | |
| def handle(i: Int): String | |
| } | |
| object SingleArgSam extends SamCompanion[SingleArgSam, Int => String] | |
| trait TwoArgSam { | |
| def handle(i: Int, str: String): String | |
| } | |
| object TwoArgSam extends SamCompanion[TwoArgSam, (Int, String) => String] | |
| test("no args") { | |
| val ss = NoArgSam(() => "42") | |
| assert(ss.handle() == "42") | |
| } | |
| test("single arg") { | |
| val ss = SingleArgSam(_.toString) | |
| assert(ss.handle(123) == "123") | |
| } | |
| test("two args") { | |
| val ss = TwoArgSam(_.toString + _) | |
| assert(ss.handle(123, "lol") == "123lol") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment