-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c32eedd
commit b40375e
Showing
7 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.paulbutcher.test | ||
|
||
import org.scalamock.scalatest.MockFactory | ||
import org.scalatest.funspec.AnyFunSpec | ||
|
||
class VarSpec extends AnyFunSpec with MockFactory { | ||
|
||
autoVerify = false | ||
|
||
trait Vars { | ||
var aVar: String | ||
var concreteVar = "foo" | ||
} | ||
|
||
it("mock traits with vars") { | ||
withExpectations { | ||
val m = mock[Vars] | ||
(m.aVar_= _).expects("foo") | ||
(() => m.aVar).expects().returning("bar") | ||
m.aVar = "foo" | ||
assertResult("bar") { | ||
m.aVar | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
shared/src/test/scala-3/com/paulbutcher/test/VarSpec.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.paulbutcher.test | ||
|
||
import org.scalamock.scalatest.MockFactory | ||
import org.scalatest.funspec.AnyFunSpec | ||
|
||
class VarSpec extends AnyFunSpec with MockFactory { | ||
|
||
trait Vars { | ||
var aVar: Int = scala.compiletime.uninitialized | ||
var concreteVar = "foo" | ||
} | ||
|
||
it("mock traits with vars") { | ||
val m = mock[Vars] | ||
m.aVar = 6 | ||
m.concreteVar = "bar" | ||
} | ||
|
||
} |
This file contains 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
This file contains 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