Skip to content

Commit

Permalink
readme about generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
goshacodes committed Oct 1, 2024
1 parent 5e8a42c commit 7fd502f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,29 @@ val overloaded = stub[Overloaded]:
.method(_.overloaded: (Int, Boolean) => Int).returns((x, y) => x)
```

### Generic types support

Current implementation has restriction of 1 expectation per method.
It is same for generic types (Maybe it will change in the future if I find a solution).

```scala 3
import backstub.*

trait TypeArgs:
def typeArgs[A](x: A): A

val typeArgsStub = stub[TypeArgs]:
Expect[TypeArgs]:
.method(_.typeArgs[Int]).returns(x => x)

typeArgsStub.typeArgs[Int](2)

typeArgsStub.times(_.typeArgs)
typeArgsStub.calls(_.typeArgs)

```


## Example
Model - [SessionCheckService.scala](modules/core/src/test/scala/backstub/SessionCheckService.scala)

Expand Down

0 comments on commit 7fd502f

Please sign in to comment.