FORTH for the SHARP PC-E500 (S)
|
11-13-2021, 12:07 PM
Post: #55
|
|||
|
|||
RE: FORTH for the SHARP PC-E500 (S)
Test Suite & Date calculation
I was curious whether the test suite works with Forth500. (https://forth-standard.org/standard/testsuite) And the answer is yes, absolutely no problem. The zip archive attached below contains the file TTESTER.FTH. It starts with the lines Code: \ TTESTER.FTH Code: T{ 1 2 3 swap -> 1 3 2 }T The first time I saw lines with T{ }T when calculating dates in Forth on this page: https://forth-ev.de/wiki/examples:daymonthyear But this page shows an example for Gforth and in Gforth a cell has 32 bits. For the Forth500 with its 16 bits per cell, double values and double functions must therefore be used in many places. Thanks to the test suite and the many test cases, I was able to check the conversion to double. The result is the DATE.FTH file in the attached zip archive. At the end of DATE.FTH there are two examples: Code: 2021 12 25 ymd2day 2dup day2dow weekday CR Saturday 42 The first day of Christmas is a Saturday and there are still 42 days until then. The file DATETEST.FTH contains the many test cases. If you load TTESTER.FTH and DATE.FTH beforehand (regardless of the order) then the test cases will be executed with INCLUDE COM: when DATETEST.FTH is loaded. Loading takes 100 seconds and immediately afterwards "passed successful" appears on the display. The test cases are therefore executed during loading! The function (ymd2day) on the website is not entirely correct. The error-free version is shown on page 16 of this pdf https://forth-ev.de/wiki/res/lib/exe/fet...018-04.pdf (ymd2day) contains an additional 1+ at the end. That the day2dow function contains a 1+ instead of a 2+ is more a matter of taste. It would be interesting to know whether the code coverage as described in this article for Gforth can also be determined with Forth500. But this requires a number of very special functions that are not part of the standard, such as current-sourceview... |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)