Skip to content

Commit 562e83a

Browse files
committed
Fix D0> and add unit test.
1 parent 28e3051 commit 562e83a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ulp-forth
22
.vscode/
33
dist/
4+
.DS_Store
45
out.bin
56
out.nonportable.S
67
out.S

pkg/forth/builtin/03_double.f

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@
4141
;
4242

4343
: D0>
44-
NIP 0>
44+
DUP 0< IF
45+
2DROP FALSE EXIT
46+
THEN
47+
0> IF
48+
DROP TRUE EXIT
49+
THEN
50+
0<>
4551
;
4652

4753
: D<>

pkg/forth/suite_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,18 @@ func TestDoubleSuite(t *testing.T) {
17631763
T{ MIN-2INT D0< -> <TRUE> }T
17641764
`,
17651765
},
1766+
{
1767+
name: "D0>",
1768+
code: `
1769+
T{ 0. D0> -> <FALSE> }T
1770+
T{ 1. D0> -> <TRUE> }T
1771+
T{ MIN-INT 0 D0> -> <TRUE> }T
1772+
T{ 0 MAX-INT D0> -> <TRUE> }T
1773+
T{ MAX-2INT D0> -> <TRUE> }T
1774+
T{ -1. D0> -> <FALSE> }T
1775+
T{ MIN-2INT D0> -> <FALSE> }T
1776+
`,
1777+
},
17661778
{
17671779
name: "D0=",
17681780
code: `

0 commit comments

Comments
 (0)