source: trunk/nomc/nomc-test-input.nom

Last change on this file was 380, checked in by cinc, 17 years ago

Compiler for a new programming language for use with NOM (C like).

File size: 5.7 KB
RevLine 
[380]1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is "NOM" Netlabs Object Model
15 *
16 * The Initial Developer of the Original Code is
17 * netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
18 * Portions created by the Initial Developer are Copyright (C) 2008
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
25 * case the provisions of the LGPL are applicable instead of those above. If
26 * you wish to allow use of your version of this file only under the terms of
27 * the LGPL, and not to allow others to use your version of this file under
28 * the terms of the CDDL, indicate your decision by deleting the provisions
29 * above and replace them with the notice and other provisions required by the
30 * LGPL. If you do not delete the provisions above, a recipient may use your
31 * version of this file under the terms of any one of the CDDL or the LGPL.
32 *
33 * ***** END LICENSE BLOCK ***** */
34/*
35 * And remember, phase 3 is near...
36 */
37 #if 0
38
39#ifndef NOM_NOMTestCase_IMPLEMENTATION_FILE
40#define NOM_NOMTestCase_IMPLEMENTATION_FILE
41#endif
42
43#if __OS2__
44#define INCL_DOS
45#include <os2.h>
46#endif /* __OS2__ */
47
48#include "string.h"
49#include <nom.h>
50#include <nomtk.h>
51
52#include "nomarray.h"
53#include "nomstring.h"
54#include "nomtestresult.h"
55#include "nomtestcase.ih"
56#include "nommethod.h"
57
58typedef boolean NOMLINK nomProc(void*, void*);
59
60NOMDLLEXPORT NOM_Scope void NOMLINK impl_NOMTestCase_setUp(NOMTestCase* nomSelf,
61 CORBA_Environment *ev)
62{
63 /* NOMTestCaseData* nomThis = NOMTestCaseGetData(nomSelf); */
64
65}
66
67NOMDLLEXPORT NOM_Scope void NOMLINK impl_NOMTestCase_tearDown(NOMTestCase* nomSelf,
68 CORBA_Environment *ev)
69{
70 /* NOMTestCaseData* nomThis = NOMTestCaseGetData(nomSelf); */
71
72}
73#endif
74
75NOMDLLEXPORT NOM_Scope NOMArray* NOMLINK impl_NOMTestCase_runTests(NOMTestCase* nomSelf,
76 CORBA_Environment *ev)
77{
78 NOMArray* resultArray=NOMArrayNew();
79 NOMArray* methodArray=NULL;
80 int a;
81
82 /* NOMTestCaseData* nomThis = NOMTestCaseGetData(nomSelf); */
83 methodArray=_nomGetMethodList(nomSelf, FALSE, NULL);
84
85 for(a=0; a<NOMArray_length(methodArray, NULL); a++)
86 {
87 char* methodName=_queryString(_getName(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL), NULL);
88
89 /* Only Methods starting with ˚test˚ are run. */
90 if(0!=strnstr( methodName, "test", 4))
91 {
92 NOMTestResult* nResult=NOMTestResultNew();
93 nomProc* nProc=_queryMethodToken(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL);
94
95 _setUp(nomSelf, NULL);
96
97 /* The name of this test */
98 _setName(nResult, _getName(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL), NULL);
99
100 /* Call the test method */
101 if(NULL!=nProc)
102 _setSuccess(nResult, nProc(nomSelf, NULL), NULL); /* TRUE if success */
103
104 /* Clean up */
105 _tearDown(nomSelf, NULL);
106 NOMArray_append(resultArray, nResult, NULL);
107 }
108 }
109
110 return resultArray;
111}
112
113#if 0
114NOMDLLEXPORT NOM_Scope NOMTestResult* NOMLINK impl_NOMTestCase_runSingleTest(NOMTestCase* nomSelf,
115 const CORBA_char* chrTestName,
116 CORBA_Environment *ev)
117{
118 NOMTestResult* nResult=NOMTestResultNew();
119 NOMString* nsName;
120 NOMArray* methodArray=NULL;
121 int a;
122
123 /* NOMTestCaseData* nomThis = NOMTestCaseGetData(nomSelf); */
124
125 /* Get list of all methods of this class */
126 methodArray=_nomGetMethodList(nomSelf, FALSE, NULL);
127
128 /* The name of this test */
129 nsName=NOMStringNew();
130 NOMString_assignString(nsName, chrTestName, NULL);
131
132 _setName(nResult, nsName, NULL);
133
134 for(a=0; a<NOMArray_length(methodArray, NULL); a++)
135 {
136 char* methodName=_queryString(_getName(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL), NULL);
137
138 if(0==strcmp( methodName, chrTestName))
139 {
140 nomProc* nProc=_queryMethodToken(NOMArray_queryObjectAtIdx(methodArray, a, NULL), NULL);
141
142 _setUp(nomSelf, NULL);
143
144 /* Call the test method */
145 if(NULL!=nProc)
146 _setSuccess(nResult, nProc(nomSelf, NULL), NULL); /* TRUE if success */
147
148 /* Clean up */
149 _tearDown(nomSelf, NULL);
150 }
151 }
152
153 return nResult;
154}
155
156
157
158NOMDLLEXPORT NOM_Scope void NOMLINK impl_NOMTestCase_setClassMgrObject(NOMTestCase* nomSelf,
159 const NOMClassMgr* nomClassMgrObject,
160 CORBA_Environment *ev)
161{
162 NOMTestCaseData* nomThis = NOMTestCaseGetData(nomSelf);
163
164 _nomClassMgrObject=nomClassMgrObject;
165
166}
167
168
169NOMDLLEXPORT NOM_Scope NOMClassMgr* NOMLINK impl_NOMTestCase_queryClassMgrObject(NOMTestCase* nomSelf,
170 CORBA_Environment *ev)
171{
172 NOMTestCaseData* nomThis = NOMTestCaseGetData(nomSelf);
173
174 return _nomClassMgrObject;
175}
176#endif
Note: See TracBrowser for help on using the repository browser.