]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/crossref/crossref-tests.factor
361b52b45f5cc81d35d0b40d3c116bb8534aa14c
[factor.git] / basis / tools / crossref / crossref-tests.factor
1 USING: math kernel sequences io.files io.pathnames
2 tools.crossref tools.crossref.private tools.test parser
3 namespaces source-files generic definitions words accessors
4 compiler.units classes ;
5 IN: tools.crossref.tests
6
7 GENERIC: predicate-test ( a -- b )
8
9 M: class predicate-test ;
10
11 M: generic predicate-test ;
12
13 [ f ] [ \ + irrelevant? ] unit-test
14 [ t ] [ \ predicate-test "engines" word-prop first irrelevant? ] unit-test
15
16 GENERIC: foo ( a b -- c )
17
18 M: integer foo + ;
19
20 "vocab:tools/crossref/test/foo.factor" run-file
21
22 [ t ] [ integer \ foo lookup-method \ + usage member? ] unit-test
23 [ t ] [ \ foo usage [ pathname? ] any? ] unit-test
24
25 ! Issues with forget
26 GENERIC: generic-forget-test-1 ( a b -- c )
27
28 M: integer generic-forget-test-1 / ;
29
30 [ t ] [
31     \ / usage [ word? ] filter
32     [ name>> "integer=>generic-forget-test-1" = ] any?
33 ] unit-test
34
35 [ ] [
36     [ \ generic-forget-test-1 forget ] with-compilation-unit
37 ] unit-test
38
39 [ f ] [
40     \ / usage [ word? ] filter
41     [ name>> "integer=>generic-forget-test-1" = ] any?
42 ] unit-test
43
44 GENERIC: generic-forget-test-2 ( a b -- c )
45
46 M: sequence generic-forget-test-2 = ;
47
48 [ t ] [
49     \ = usage [ word? ] filter
50     [ name>> "sequence=>generic-forget-test-2" = ] any?
51 ] unit-test
52
53 [ ] [
54     [ M\ sequence generic-forget-test-2 forget ] with-compilation-unit
55 ] unit-test
56
57 [ f ] [
58     \ = usage [ word? ] filter
59     [ name>> "sequence=>generic-forget-test-2" = ] any?
60 ] unit-test