-
Notifications
You must be signed in to change notification settings - Fork 649
Expand file tree
/
Copy pathHasTestingDirectorySpec.scala
More file actions
75 lines (43 loc) · 1.78 KB
/
HasTestingDirectorySpec.scala
File metadata and controls
75 lines (43 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// SPDX-License-Identifier: Apache-2.0
package chiselTests.testing
import chisel3.testing.HasTestingDirectory
import java.nio.file.Paths
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class HasTestingDirectorySpec extends AnyFlatSpec with Matchers {
val foo = new HasTestingDirectory {
override def getDirectory = Paths.get("foo", "bar")
}
behavior of ("HasTestingDirectory.getDirectory")
it should ("return the specified output directory") in {
foo.getDirectory should be(Paths.get("foo", "bar"))
}
behavior of ("HasTestingDirectory.withSubdirectory")
it should ("return a subdirectory of the original directory") in {
val baz = foo.withSubdirectory("baz")
baz.getDirectory should be(Paths.get("foo", "bar", "baz"))
}
behavior of ("HasTestingDirectory.timestamp")
it should ("return the same directory for a given instance of the type class") in {
val foo = HasTestingDirectory.timestamp
foo.getDirectory should be(foo.getDirectory)
}
it should ("return different directories for separate instances of the type class") in {
val foo = HasTestingDirectory.timestamp
val bar = HasTestingDirectory.timestamp
foo.getDirectory should not be (bar.getDirectory)
}
behavior of ("HasTestingDirectory.default")
it should ("return different directories for different functions that require a type class implementation") in {
def foo(implicit testingDirectory: HasTestingDirectory) = {
testingDirectory.getDirectory
}
foo should not be (foo)
}
it should ("allow the user to force the same directory by creating an implicit val") in {
def foo(implicit testingDirectory: HasTestingDirectory) = {
testingDirectory.getDirectory
}
foo should be(foo)
}
}