-
Notifications
You must be signed in to change notification settings - Fork 1
/
list.test.fs
44 lines (32 loc) · 1.01 KB
/
list.test.fs
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
require list.fs
also list.fs
: must-equal <> if abort" " else ." OK " then ;
variable list1
variable list2
: run-test
list:create list1 !
list1 @ 1 list:append list1 !
list1 @ 2 list:append list1 !
list1 @ 3 list:append list1 !
list1 @ 4 list:append list1 !
list1 @ 5 list:append list1 !
list1 @ 6 list:append list1 !
." list:for-each -> "
[: . ;] list1 @ list:for-each ." visually assert: 1 2 3 4 5 6" cr
." list:nth -> "
list1 @ 2 list:nth 3 must-equal cr
." list:reduce -> "
list1 @ 1 [: * ;] list:reduce 720 must-equal cr
." list:length -> "
list1 @ list:length 6 must-equal cr
." list:map -> "
list1 @ [: 2 * ;] list:map list2 !
list2 @ list:length list1 @ list:length must-equal
list2 @ 0 list:nth list1 @ 0 list:nth 2 * must-equal
list2 @ 1 list:nth list1 @ 1 list:nth 2 * must-equal
list2 @ 2 list:nth list1 @ 2 list:nth 2 * must-equal
list2 @ 3 list:nth list1 @ 3 list:nth 2 * must-equal cr
." list:some -> "
list1 @ [: 3 = ;] list:some true must-equal cr
;
run-test