Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add `infix fun String.selfieIs` (similar to Kotest `shouldBe`)

Đang mở
#214 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
kotlin
Lĩnh vực
testing

Hướng nghiên cứu

Bắt đầu với jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/SourceFile.kt, tại logic parsing được liên kết quanh các dòng 105–111. Xem xét các entry point selfieIs được đề xuất của com.diffplug.selfie và com.diffplug.selfie.coroutines, sau đó lần theo cách toBe_TODO, toBe, //selfieonce và //SELFIEWRITE được xử lý. Công việc được xem là hoàn tất khi các literal nhiều dòng infix và cả dạng thông thường lẫn dạng suspend đều hoạt động với các ví dụ được hiển thị.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement jvm

Kotest has a very nice shouldBe method:

someFunction() shouldBe "some value"

It would be handy if Selfie had an infix version:

someFunction() selfieIs null // equivalent to `toBe_TODO`, run and it becomes
someFunction() selfieIs "some value"

And all the //selfieonce, //SELFIEWRITE would work too if implemented roughly like so:

// in com.diffplug.selfie
infix fun String.selfieIs(expected: String?) : Unit {
  if (expected == null) {
    Selfie.expectSelfie(this).toBe_TODO()
  } else {
    Selfie.expectSelfie(this).toBe(expected)
  }
}

// in com.diffplug.selfie.coroutines
suspend infix fun String.selfieIs(expected: String?) : Unit {
  if (expected == null) {
    Selfie.expectSelfie(this).toBe_TODO()
  } else {
    Selfie.expectSelfie(this).toBe(expected)
  }
}

The main challenge will be adapting this code to parse infix multiline literals

https://github.com/diffplug/selfie/blob/952a4ebfdf4911deeb08a7378048c80a0a9bb3ff/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/SourceFile.kt#L105-L111

Ngôn ngữ chính
Kotlin
Star
101
Fork
18
Merge trung bình
6 ngày 11 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của diffplug/selfie

Tất cả issue của diffplug/selfie

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.