Skip to content

Commit 3046c24

Browse files
author
Joseph Cooper
committed
Rename JVM File helper functions
N.B. `text` and `bytes` are renamed in separate commits
1 parent d59cbdd commit 3046c24

File tree

1 file changed

+36
-8
lines changed
  • assertk/src/jvmMain/kotlin/assertk/assertions

1 file changed

+36
-8
lines changed

assertk/src/jvmMain/kotlin/assertk/assertions/file.kt

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,50 @@ import kotlin.io.readBytes
1111
/**
1212
* Returns an assert on the file's name.
1313
*/
14-
fun Assert<File>.name() = having("name", File::getName)
14+
fun Assert<File>.havingName() = having("name", File::getName)
15+
16+
@Deprecated(
17+
message = "Function name has been renamed to havingName",
18+
replaceWith = ReplaceWith("havingName()"),
19+
level = DeprecationLevel.WARNING
20+
)
21+
fun Assert<File>.name() = havingName()
1522

1623
/**
1724
* Returns an assert on the file's path.
1825
*/
19-
fun Assert<File>.path() = having("path", File::getPath)
26+
fun Assert<File>.havingPath() = having("path", File::getPath)
27+
28+
@Deprecated(
29+
message = "Function path has been renamed to havingPath",
30+
replaceWith = ReplaceWith("havingPath()"),
31+
level = DeprecationLevel.WARNING
32+
)
33+
fun Assert<File>.path() = havingPath()
2034

2135
/**
2236
* Returns an assert on the file's parent.
2337
*/
24-
fun Assert<File>.parent() = having("parent", File::getParent)
38+
fun Assert<File>.havingParent() = having("parent", File::getParent)
39+
40+
@Deprecated(
41+
message = "Function parent has been renamed to havingParent",
42+
replaceWith = ReplaceWith("havingParent()"),
43+
level = DeprecationLevel.WARNING
44+
)
45+
fun Assert<File>.parent() = havingParent()
2546

2647
/**
2748
* Returns an assert on the file's extension.
2849
*/
29-
fun Assert<File>.extension() = having("extension", File::extension)
50+
fun Assert<File>.havingExtension() = having("extension", File::extension)
51+
52+
@Deprecated(
53+
message = "Function extension has been renamed to havingExtension",
54+
replaceWith = ReplaceWith("havingExtension()"),
55+
level = DeprecationLevel.WARNING
56+
)
57+
fun Assert<File>.extension() = havingExtension()
3058

3159
/**
3260
* Returns an assert on the file's contents as text.
@@ -86,28 +114,28 @@ fun Assert<File>.isNotHidden() = given { actual ->
86114
* Asserts the file has the expected name.
87115
*/
88116
fun Assert<File>.hasName(expected: String) {
89-
name().isEqualTo(expected)
117+
havingName().isEqualTo(expected)
90118
}
91119

92120
/**
93121
* Asserts the file has the expected path.
94122
*/
95123
fun Assert<File>.hasPath(expected: String) {
96-
path().isEqualTo(File(expected).path)
124+
havingPath().isEqualTo(File(expected).path)
97125
}
98126

99127
/**
100128
* Asserts the file has the expected parent path.
101129
*/
102130
fun Assert<File>.hasParent(expected: String) {
103-
parent().isEqualTo(File(expected).path)
131+
havingParent().isEqualTo(File(expected).path)
104132
}
105133

106134
/**
107135
* Asserts the file has the expected extension.
108136
*/
109137
fun Assert<File>.hasExtension(expected: String) {
110-
extension().isEqualTo(expected)
138+
havingExtension().isEqualTo(expected)
111139
}
112140

113141
/**

0 commit comments

Comments
 (0)