Skip to content

Commit f2c2b9e

Browse files
committed
Test: convert empty method to borrowing getter
it's cheap enough that it can be a computed property; and gives more test coverage. (cherry picked from commit af9ce5f)
1 parent 4087097 commit f2c2b9e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

test/Inputs/Swiftskell.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ extension List where Element: ~Copyable {
239239
/// Basic utilities
240240
extension List where Element: ~Copyable {
241241
/// Is this list empty?
242-
public borrowing func empty() -> Bool {
243-
switch self {
244-
case .empty: return true
245-
case .cons(_, _): return false
242+
public var isEmpty: Bool {
243+
borrowing get {
244+
switch self {
245+
case .empty: true
246+
case .cons(_, _): false
247+
}
246248
}
247249
}
248250

test/Interpreter/moveonly_swiftskell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ func testListBasic() {
4141
var items = List<File>(length: 5) { .init($0) }
4242
print(items.show()) // CHECK: [0, 1, 2, 3, 4, ]
4343
check(items.length() == 5)
44-
check(!items.empty())
44+
check(!items.isEmpty)
4545

4646
items = items.reverse()
4747
check(items.length() == 5)
4848
print(items.show()) // CHECK: [4, 3, 2, 1, 0, ]
4949

5050
items = .empty
5151
check(items.length() == 0)
52-
check(items.empty())
52+
check(items.isEmpty)
5353

5454
let nums = List<Int>().push(7).push(7).push(3)
5555
print(nums.show()) // CHECK: [7, 7, 3, ]

0 commit comments

Comments
 (0)