<commit_before>
(load-relative "loadtest.ss")

(Section 'date)

(require (lib "date.ss"))

(define (test-find s m h d mo y)
  (let* ([secs (find-seconds s m h d mo y)]
	 [date (seconds->date secs)])
    (test #t 'same
	  (and (= s (date-second date))
	       (= m (date-minute date))
	       (= h (date-hour date))
	       (= d (date-day date))
	       (= mo (date-month date))
	       (= y (date-year date))))))

(test-find 0 0 0 1 4 1975)
(test-find 0 0 0 1 4 2005)

; Bad dates
(err/rt-test (find-seconds 0 0 0 0 0 1990) exn:fail?)
(err/rt-test (find-seconds 0 0 0 0 1 1990) exn:fail?)
(err/rt-test (find-seconds 0 0 0 1 0 1990) exn:fail?)

; Early/late
(err/rt-test (find-seconds 0 0 0 1 1 1490) exn:fail?)
(err/rt-test (find-seconds 0 0 0 1 1 2890) exn:fail?)

; 1990 April 1 was start of daylight savings:
(test-find 0 0 1 1 4 1990) ; ok
(let ([s (find-seconds 1 0 3 1 4 1990)]) ; ok
  (when (date-dst? (seconds->date s))
	; We have daylight savings here; 2:01 AM doesn't exist
	(err/rt-test (find-seconds 0 1 2 1 4 1990) exn:fail?)
	; This date is ambiguous; find-seconds should find
	;  one of the two possible values, though:
	(test-find 0 30 1 27 10 1996)))

;; bug fixes
(test "JD 12" julian/scalinger->string 12)
(test "JD 123" julian/scalinger->string 123)

(report-errs)<commit_msg>fix date test for machines with 64-bit dates<commit_after>
(load-relative "loadtest.ss")

(Section 'date)

(require (lib "date.ss"))

(define (test-find s m h d mo y)
  (let* ([secs (find-seconds s m h d mo y)]
	 [date (seconds->date secs)])
    (test #t 'same
	  (and (= s (date-second date))
	       (= m (date-minute date))
	       (= h (date-hour date))
	       (= d (date-day date))
	       (= mo (date-month date))
	       (= y (date-year date))))))

(test-find 0 0 0 1 4 1975)
(test-find 0 0 0 1 4 2005)

;; Bad dates
(err/rt-test (find-seconds 0 0 0 0 0 1990) exn:fail?)
(err/rt-test (find-seconds 0 0 0 0 1 1990) exn:fail?)
(err/rt-test (find-seconds 0 0 0 1 0 1990) exn:fail?)

;; Early/late
(unless (eq? (expt 2 40) (eq-hash-code (expt 2 40))) ; 64-bit-machine?
  (err/rt-test (find-seconds 0 0 0 1 1 1490) exn:fail?)
  (err/rt-test (find-seconds 0 0 0 1 1 2890) exn:fail?))

;; 1990 April 1 was start of daylight savings:
(test-find 0 0 1 1 4 1990) ; ok
(let ([s (find-seconds 1 0 3 1 4 1990)]) ; ok
  (when (date-dst? (seconds->date s))
    ;; We have daylight savings here; 2:01 AM doesn't exist
    (err/rt-test (find-seconds 0 1 2 1 4 1990) exn:fail?)
    ;; This date is ambiguous; find-seconds should find
    ;;  one of the two possible values, though:
    (test-find 0 30 1 27 10 1996)))

;; bug fixes
(test "JD 12" julian/scalinger->string 12)
(test "JD 123" julian/scalinger->string 123)

(report-errs)
{'fraction_non_alphanumeric': 0.15808823529411764, 'fraction_numerical': 0.09191176470588236, 'mean_word_length': 2.9838945827232797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1858669', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1032, 'n_words': 404}