]> gitweb.factorcode.org Git - factor.git/blob - basis/windows/com/com-tests.factor
Remove <uint> *uint and friends. Hopefully remove the last usages of these words
[factor.git] / basis / windows / com / com-tests.factor
1 USING: kernel windows.com windows.com.syntax windows.ole32
2 windows.types alien alien.syntax tools.test libc alien.c-types
3 namespaces arrays continuations accessors math windows.com.wrapper
4 windows.com.wrapper.private destructors effects compiler.units ;
5 IN: windows.com.tests
6
7 COM-INTERFACE: ISimple IUnknown {216fb341-0eb2-44b1-8edb-60b76e353abc}
8     HRESULT returnOK ( )
9     HRESULT returnError ( ) ;
10
11 COM-INTERFACE: IInherited ISimple {9620ecec-8438-423b-bb14-86f835aa40dd}
12     int getX ( )
13     void setX ( int newX ) ;
14
15 COM-INTERFACE: IUnrelated IUnknown {b06ac3f4-30e4-406b-a7cd-c29cead4552c}
16     int xPlus ( int y )
17     int xMulAdd ( int mul, int add ) ;
18
19 COM-INTERFACE: ISelfReferential IUnknown {d4f45bf8-f720-4701-a09d-e8e341981121}
20     ISelfReferential* selfReference ( ) ;
21
22 { GUID: {216fb341-0eb2-44b1-8edb-60b76e353abc} } [ ISimple-iid ] unit-test
23 { GUID: {9620ecec-8438-423b-bb14-86f835aa40dd} } [ IInherited-iid ] unit-test
24 { GUID: {00000000-0000-0000-C000-000000000046} } [ IUnknown-iid ] unit-test
25 { GUID: {b06ac3f4-30e4-406b-a7cd-c29cead4552c} } [ IUnrelated-iid ] unit-test
26
27 { (( -- iid )) } [ \ ISimple-iid stack-effect ] unit-test
28 { (( this -- HRESULT )) } [ \ ISimple::returnOK stack-effect ] unit-test
29 { (( this -- int )) } [ \ IInherited::getX stack-effect ] unit-test
30 { (( this newX -- )) } [ \ IInherited::setX stack-effect ] unit-test
31 { (( this mul add -- int )) } [ \ IUnrelated::xMulAdd stack-effect ] unit-test
32
33 SYMBOL: +test-wrapper+
34 SYMBOL: +guinea-pig-implementation+
35 SYMBOL: +orig-wrapped-objects+
36
37 +wrapped-objects+ get-global clone +orig-wrapped-objects+ set-global
38
39 TUPLE: test-implementation x ;
40 C: <test-implementation> test-implementation
41
42 [
43     {
44         { IInherited {
45             [ drop S_OK ] ! ISimple::returnOK
46             [ drop E_FAIL ] ! ISimple::returnError
47             [ x>> ] ! IInherited::getX
48             [ >>x drop ] ! IInherited::setX
49         } }
50         { IUnrelated {
51             [ [ x>> ] [ + ] bi* ] ! IUnrelated::xPlus
52             [ [ x>> ] [ * ] [ + ] tri* ] ! IUnrelated::xMulAdd
53         } }
54     } <com-wrapper>
55     dup +test-wrapper+ set [
56
57         0 <test-implementation> swap com-wrap
58         dup +guinea-pig-implementation+ set [ drop
59
60             S_OK 1array [ +guinea-pig-implementation+ get ISimple::returnOK ] unit-test
61             E_FAIL long <ref> long deref 1array [ +guinea-pig-implementation+ get ISimple::returnError ] unit-test
62             20 1array [
63                 +guinea-pig-implementation+ get
64                 [ 20 IInherited::setX ]
65                 [ IInherited::getX ] bi
66             ] unit-test
67             420 1array [
68                 +guinea-pig-implementation+ get
69                 IUnrelated-iid com-query-interface
70                 [ 20 20 IUnrelated::xMulAdd ] with-com-interface
71             ] unit-test
72             40 1array [
73                 +guinea-pig-implementation+ get
74                 IUnrelated-iid com-query-interface
75                 [ 20 IUnrelated::xPlus ] with-com-interface
76             ] unit-test
77
78             +guinea-pig-implementation+ get 1array [
79                 +guinea-pig-implementation+ get com-add-ref
80             ] unit-test
81
82             { } [ +guinea-pig-implementation+ get com-release ] unit-test
83
84             +guinea-pig-implementation+ get 1array [
85                 +guinea-pig-implementation+ get IUnknown-iid com-query-interface
86                 dup com-release
87             ] unit-test
88             +guinea-pig-implementation+ get 1array [
89                 +guinea-pig-implementation+ get ISimple-iid com-query-interface
90                 dup com-release
91             ] unit-test                                              
92             void* heap-size +guinea-pig-implementation+ get <displaced-alien>
93             +guinea-pig-implementation+ get                                           
94             2array [
95                 +guinea-pig-implementation+ get IUnrelated-iid com-query-interface
96                 dup ISimple-iid com-query-interface
97                 over com-release dup com-release
98             ] unit-test
99
100         ] with-com-interface
101
102     ] with-disposal
103 ] with-compilation-unit
104
105 ! Ensure that we freed +guinea-pig-implementation
106 +orig-wrapped-objects+ get-global 1array [ +wrapped-objects+ get-global ] unit-test