-
Notifications
You must be signed in to change notification settings - Fork 222
Expand file tree
/
Copy pathcanonicalize.factor
More file actions
66 lines (57 loc) · 1.45 KB
/
canonicalize.factor
File metadata and controls
66 lines (57 loc) · 1.45 KB
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
57
58
59
60
61
62
63
64
65
66
USING: multi-methods tools.test math sequences namespaces system
kernel strings ;
IN: multi-methods.tests
{ { POSTPONE: f integer } } [ { f integer } canonicalize-specializer-0 ] unit-test
: setup-canon-test ( -- )
0 args set
V{ } clone hooks set ;
: canon-test-1 ( -- seq )
{ integer { cpu x86 } sequence } canonicalize-specializer-1 ;
{ { { -2 integer } { -1 sequence } { cpu x86 } } } [
[
setup-canon-test
canon-test-1
] with-scope
] unit-test
{ { { 0 integer } { 1 sequence } { 2 x86 } } } [
[
setup-canon-test
canon-test-1
canonicalize-specializer-2
] with-scope
] unit-test
{ { integer sequence x86 } } [
[
setup-canon-test
canon-test-1
canonicalize-specializer-2
args get hooks get length + total set
canonicalize-specializer-3
] with-scope
] unit-test
CONSTANT: example-1
{
{ { { cpu x86 } { os linux } } "a" }
{ { { cpu ppc } } "b" }
{ { string { os windows } } "c" }
}
{
{
{ { object x86 linux } "a" }
{ { object ppc object } "b" }
{ { string object windows } "c" }
}
{ cpu os }
} [
example-1 canonicalize-specializers
] unit-test
{
{
{ { object x86 linux } [ drop drop "a" ] }
{ { object ppc object } [ drop drop "b" ] }
{ { string object windows } [ drop drop "c" ] }
}
[ \ cpu get \ os get ]
} [
example-1 prepare-methods
] unit-test