-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframework.4th
executable file
·56 lines (49 loc) · 1.73 KB
/
framework.4th
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
\ Testing framework compatible with codewars.com
\
\ Copyright 2018 nomennescio
\
\ This program is free software: you can redistribute it and/or modify
\ it under the terms of the GNU Lesser Public License as published by
\ the Free Software Foundation, either version 3 of the License, or
\ (at your option) any later version.
\
\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\ GNU Lesser Public License for more details.
\
\ You should have received a copy of the GNU Lesser Public License
\ along with this program. If not, see <https://www.gnu.org/licenses/>.
decimal
s" test/ttester.fs" included
: #ms ( dmicroseconds -- len c-addr ) <# # # # [char] . hold #s #> ;
: describe#{ ( len c-addr -- ) cr ." <DESCRIBE::>" type cr utime ;
: it#{ ( len c-addr -- ) cr ." <IT::>" type cr utime ;
: }# ( -- ) utime cr ." <COMPLETEDIN::>" 2swap d- #ms type ." ms" cr ;
: failed# ( -- ) cr ." <FAILED::>" ;
: passed# ( -- ) cr ." <PASSED::>" ;
create EXPECTED-RESULTS 32 cells allot
variable RESULTS
variable DIFFERENCES
: <{ T{ ;
: }>
depth ACTUAL-DEPTH @ = if
depth START-DEPTH @ > if
depth START-DEPTH @ - dup RESULTS ! 0 do
dup EXPECTED-RESULTS i cells + !
ACTUAL-RESULTS i cells + @ <> DIFFERENCES +!
loop
DIFFERENCES @ if
failed# ." Expected "
RESULTS @ 0 do EXPECTED-RESULTS i cells + @ . loop
." , got "
RESULTS @ 0 do ACTUAL-RESULTS i cells + @ . loop
cr
else
passed# ." Test Passed" cr
then
then
else
failed# ." Wrong number of results, expected " ACTUAL-DEPTH @ . ." , got " depth . cr
then
F} ;