Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions devel/210_16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# [210_16] srfi-19 date-year-day 添加测试

## 添加 srfi-19 date-year-day 添加测试

## 如何测试

```shell
# 可能需要清除缓存
# rm .xmake/ build/ -r
xmake f -vyD
xmake b goldfish
./bin/goldfish tests/goldfish/liii/time-test.scm
```


1 change: 1 addition & 0 deletions goldfish/srfi/srfi-19.scm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
make-date date?
date-nanosecond date-second date-minute date-hour
date-day date-month date-year date-zone-offset
date-year-day
;; Time/Date/Julian Day/Modified Julian Day Converters
time-utc->date date->time-utc
;; Date to String/String to Date Converters
Expand Down
12 changes: 12 additions & 0 deletions tests/goldfish/liii/time-test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,18 @@ wrong-type-arg
(check (date-year d) => 2000)
(check (date-zone-offset d) => -14400))

;; Test date-year-day
(let ((d1 (make-date 0 0 0 0 1 1 2023 0)) ; non-leap year
(d2 (make-date 0 0 0 0 1 3 2023 0))
(d3 (make-date 0 0 0 0 1 3 2024 0)) ; leap year
(d4 (make-date 0 0 0 0 31 12 2023 0))
(d5 (make-date 0 0 0 0 31 12 2024 0))) ; negative year
(check (date-year-day d1) => 1)
(check (date-year-day d2) => 60)
(check (date-year-day d3) => 61)
(check (date-year-day d4) => 365)
(check (date-year-day d5) => 366))

;; Test error conditions
(check-catch 'wrong-type-arg (date-nanosecond "not-a-date"))
(check-catch 'wrong-type-arg (date-second 123))
Expand Down