Skip to content

Commit

Permalink
Add unit tests and doc for even? and odd? in (liii base)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ancker-0 authored Nov 24, 2024
1 parent 7d2922c commit a38a0c1
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
52 changes: 50 additions & 2 deletions Goldfish.tmu
Original file line number Diff line number Diff line change
Expand Up @@ -1471,9 +1471,57 @@
\;
</scm-chunk>

<value|r7rs><paragraph|odd?><index|odd?>
<value|r7rs><paragraph|odd?><index|odd?><scm|((x integer?)) =\<gtr\> boolean?>

<value|r7rs><paragraph|even?><index|even?>
判断一个整数是否是奇数。

<\scm-chunk|tests/goldfish/liii/base-test.scm|true|true>
(check-true (odd? 1))

(check-false (odd? 0))

\;

(check-catch 'wrong-type-arg (odd? 1+i))

(check-catch 'wrong-type-arg (odd? 1.0))

(check-catch 'wrong-type-arg (odd? 0.0))

(check-catch 'wrong-type-arg (odd? #\\A))

(check-catch 'wrong-type-arg (odd? #t))

(check-catch 'wrong-type-arg (odd? #f))

\;
</scm-chunk>

<value|r7rs><paragraph|even?><index|even?><scm|((x integer?)) =\<gtr\> boolean?>

判断一个整数是否是偶数。

<\scm-chunk|tests/goldfish/liii/base-test.scm|true|true>
(check-true (even? 0))

(check-false (even? 1))

\;

(check-catch 'wrong-type-arg (even? 0.0))

(check-catch 'wrong-type-arg (even? 1.0))

(check-catch 'wrong-type-arg (even? 1+i))

(check-catch 'wrong-type-arg (even? #\\A))

(check-catch 'wrong-type-arg (even? #t))

(check-catch 'wrong-type-arg (even? #f))

\;
</scm-chunk>

<value|r7rs><paragraph|floor><index|floor><scm|(x) =\<gtr\> integer>

Expand Down
20 changes: 20 additions & 0 deletions tests/goldfish/liii/base-test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,26 @@
(check-catch 'wrong-type-arg (negative? 'symbol))
(check-catch 'wrong-type-arg (negative? '(1 2 3)))

(check-true (odd? 1))
(check-false (odd? 0))

(check-catch 'wrong-type-arg (odd? 1+i))
(check-catch 'wrong-type-arg (odd? 1.0))
(check-catch 'wrong-type-arg (odd? 0.0))
(check-catch 'wrong-type-arg (odd? #\A))
(check-catch 'wrong-type-arg (odd? #t))
(check-catch 'wrong-type-arg (odd? #f))

(check-true (even? 0))
(check-false (even? 1))

(check-catch 'wrong-type-arg (even? 0.0))
(check-catch 'wrong-type-arg (even? 1.0))
(check-catch 'wrong-type-arg (even? 1+i))
(check-catch 'wrong-type-arg (even? #\A))
(check-catch 'wrong-type-arg (even? #t))
(check-catch 'wrong-type-arg (even? #f))

(check (floor 1.1) => 1.0)
(check (floor 1) => 1)
(check (floor 1/2) => 0)
Expand Down

0 comments on commit a38a0c1

Please sign in to comment.