Diff of /test/trunk/ooRexx/base/directives/ATTRIBUTE.testGroup [000000] .. [r8523]  Maximize  Restore

  Switch to unified view

a b/test/trunk/ooRexx/base/directives/ATTRIBUTE.testGroup
1
#!/usr/bin/rexx
2
/*
3
  SVN Revision: $Rev: 3371 $
4
  Change Date:  $Date: 2008-09-21 00:33:29 -0400 (Sun, 21 Sep 2008) $
5
*/
6
/*----------------------------------------------------------------------------*/
7
/*                                                                            */
8
/* Copyright (c) 2007-2008 Rexx Language Association. All rights reserved.    */
9
/*                                                                            */
10
/* This program and the accompanying materials are made available under       */
11
/* the terms of the Common Public License v1.0 which accompanies this         */
12
/* distribution. A copy is also available at the following address:           */
13
/* http://www.oorexx.org/license.html                                         */
14
/*                                                                            */
15
/* Redistribution and use in source and binary forms, with or                 */
16
/* without modification, are permitted provided that the following            */
17
/* conditions are met:                                                        */
18
/*                                                                            */
19
/* Redistributions of source code must retain the above copyright             */
20
/* notice, this list of conditions and the following disclaimer.              */
21
/* Redistributions in binary form must reproduce the above copyright          */
22
/* notice, this list of conditions and the following disclaimer in            */
23
/* the documentation and/or other materials provided with the distribution.   */
24
/*                                                                            */
25
/* Neither the name of Rexx Language Association nor the names                */
26
/* of its contributors may be used to endorse or promote products             */
27
/* derived from this software without specific prior written permission.      */
28
/*                                                                            */
29
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS        */
30
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT          */
31
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS          */
32
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT   */
33
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,      */
34
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED   */
35
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,        */
36
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY     */
37
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING    */
38
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS         */
39
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.               */
40
/*                                                                            */
41
/*----------------------------------------------------------------------------*/
42
  parse source . . fileSpec
43
  group = .TestGroup~new(fileSpec)
44
45
  group~add(.ATTRIBUTE.testGroup)
46
47
  if group~isAutomatedTest then return group
48
49
  testResult = group~suite~execute~~print
50
51
return testResult
52
-- End of entry point.
53
54
::requires 'ooTest.frm'
55
56
::class "ATTRIBUTE.testGroup" subclass ooTestCase public
57
58
::method test001
59
60
  -- test how the methods are created
61
  getmethod = .test~instanceMethod("V1")
62
  setmethod = .test~instanceMethod("V1=")
63
  self~assertFalse(getMethod~isPrivate)
64
  self~assertTrue(getMethod~isGuarded)
65
  self~assertTrue(getMethod~isProtected)
66
  self~assertFalse(setMethod~isPrivate)
67
  self~assertTrue(setMethod~isGuarded)
68
  self~assertTrue(setMethod~isProtected)
69
70
  -- test how the methods are created
71
  getmethod = .test~new~instanceMethod("V1")
72
  setmethod = .test~new~instanceMethod("V1=")
73
  self~assertFalse(getMethod~isPrivate)
74
  self~assertFalse(getMethod~isGuarded)
75
  self~assertFalse(getMethod~isProtected)
76
  self~assertFalse(setMethod~isPrivate)
77
  self~assertFalse(setMethod~isGuarded)
78
  self~assertFalse(setMethod~isProtected)
79
80
  getmethod = .test~instanceMethod("V2")
81
  setmethod = .test~instanceMethod("V2=")
82
  self~assertFalse(getMethod~isPrivate)
83
  self~assertFalse(getMethod~isGuarded)
84
  self~assertTrue(getMethod~isProtected)
85
  self~assertFalse(setMethod~isPrivate)
86
  self~assertFalse(setMethod~isGuarded)
87
  self~assertTrue(setMethod~isProtected)
88
89
  -- test how the methods are created
90
  getmethod = .test~new~instanceMethod("V2")
91
  setmethod = .test~new~instanceMethod("V2=")
92
  self~assertFalse(getMethod~isPrivate)
93
  self~assertFalse(getMethod~isGuarded)
94
  self~assertTrue(getMethod~isProtected)
95
  self~assertFalse(setMethod~isPrivate)
96
  self~assertFalse(setMethod~isGuarded)
97
  self~assertTrue(setMethod~isProtected)
98
99
  test = .test~new
100
  self~assertSame("Fred", .test~v1)
101
  self~assertSame("Rick", test~v1)
102
  .test~v1 = "Joe"
103
  self~assertSame("Joe", .test~v1)
104
  self~assertSame("Rick", test~v1)
105
  test~v1 = "Larry"
106
  self~assertSame("Joe", .test~v1)
107
  self~assertSame("Larry", test~v1)
108
109
  self~assertSame("George", .test~v2)
110
  self~assertSame("David", test~v2)
111
  .test~v2 = "Curly"
112
  self~assertSame("Curly", .test~v2)
113
  self~assertSame("David", test~v2)
114
  test~v2 = "Moe"
115
  self~assertSame("Curly", .test~v2)
116
  self~assertSame("Moe", test~v2)
117
118
  self~assertSame("Mike", .test~v3)
119
  self~assertSame("Mark", test~v3)
120
  .test~v3 = "Chip"
121
  self~assertSame("Chip", .test~v3)
122
  self~assertSame("Mark", test~v3)
123
  test~v3 = "Walter"
124
  self~assertSame("Chip", .test~v3)
125
  self~assertSame("Walter", test~v3)
126
127
  self~assertSame("V4", .test~v4)
128
  self~assertSame("V4", test~v4)
129
  .test~v4 = "Jon"
130
  self~assertSame("Jon", .test~v4)
131
  self~assertSame("V4", test~v4)
132
  test~v4 = "Brandon"
133
  self~assertSame("Jon", .test~v4)
134
  self~assertSame("Brandon", test~v4)
135
136
::method test002
137
  self~expectSyntax(93.965)
138
  .test~v5
139
140
::method test003
141
  self~expectSyntax(93.965)
142
  .test~new~v5
143
144
::method test004
145
  self~expectSyntax(93.965)
146
  .test~v5 = 123
147
148
::method test005
149
  self~expectSyntax(93.965)
150
  .test~new~v5 = 123
151
152
::method test006
153
  x = .test~v6
154
  self~expectSyntax(93.965)
155
  .test~v6 = 123
156
157
::method test007
158
  x = .test~new~v6
159
  self~expectSyntax(93.965)
160
  .test~new~v6 = 123
161
162
::method test008
163
  .test~v7 = 123
164
  self~expectSyntax(93.965)
165
  x = .test~v7
166
167
::method test009
168
  .test~new~v7 = 123
169
  self~expectSyntax(93.965)
170
  x = .test~new~v7
171
172
173
174
/** The following are tests syntax errors with the attribute directive.  Since
175
 *  putting incorrect syntax for the directive in this file would cause the test
176
 *  group to not run, the bad syntax tests are done by using the .Package class.
177
 *  A package is created with the code for the test.  The syntax errors are then
178
 *  raised during the instantiation of the Package object, when the code is
179
 *  parsed.
180
 */
181
::method test_dup_abstract
182
  self~assertSyntaxError(25.925, -
183
     "return 0", -
184
     "::class 'TestClass'", -
185
     "::attribute foo abstract abstract")
186
187
::method test_bad_name
188
  self~assertSyntaxError(99.925, -
189
     "return 0", -
190
     "::class 'TestClass'", -
191
     "::attribute 1234")
192
193
::method test_dup_attr
194
  self~assertSyntaxError(99.931, -
195
     "return 0", -
196
     "::class 'TestClass'", -
197
     "::attribute foo", -
198
     "::attribute foo")
199
200
::method test_dup_attr_2
201
  self~assertSyntaxError(99.931, -
202
     "return 0", -
203
     "::class 'TestClass'", -
204
     "::attribute foo get", -
205
     "::attribute foo")
206
207
::method test_dup_attr_3
208
  self~assertSyntaxError(99.931, -
209
     "return 0", -
210
     "::class 'TestClass'", -
211
     "::attribute foo set", -
212
     "::attribute foo")
213
214
::method test_dup_attr_4
215
  self~assertSyntaxError(99.931, -
216
     "return 0", -
217
     "::class 'TestClass'", -
218
     "::method foo", -
219
     "::attribute foo get")
220
221
::method test_dup_attr_5
222
  self~assertSyntaxError(99.931, -
223
     "return 0", -
224
     "::class 'TestClass'", -
225
     "::method 'foo='", -
226
     "::attribute foo set")
227
228
::method test_bad_code_body
229
  self~assertSyntaxError(99.937, -
230
     "return 0", -
231
     "::class 'TestClass'", -
232
     "::attribute foo", -
233
     "  return .true")
234
235
::method test_private_1
236
  test = .test~new
237
  test~v8set(123)
238
  self~assertSame(123, test~v8get)
239
  self~expectSyntax(97.1)
240
  test~v8 = 123
241
242
::method test_private_2
243
  test = .test~new
244
  test~v8set(123)
245
  self~assertSame(123, test~v8get)
246
  self~expectSyntax(97.1)
247
  x = test~v8
248
249
::method test_private_3
250
  test = .test~new
251
  test~v9 = 123
252
  self~assertSame(123, test~v9get)
253
  self~expectSyntax(97.1)
254
  x = test~v9
255
256
::method test_private_4
257
  test = .test~new
258
  test~v10set(123)
259
  self~assertSame(123, test~v10)
260
  self~expectSyntax(97.1)
261
  test~v10 = 123
262
263
::method test_external_1
264
  self~assertSyntaxError(19.905, -
265
     "return 0", -
266
     "::class 'TestClass'", -
267
     "::attribute foo external")
268
269
::method test_external_2
270
  self~assertSyntaxError(19.905, -
271
     "return 0", -
272
     "::class 'TestClass'", -
273
     "::attribute foo external mylib")
274
275
::method test_external_3
276
  self~assertSyntaxError(99.917, -
277
     "return 0", -
278
     "::class 'TestClass'", -
279
     "::attribute foo external 'mylib'")
280
281
::method test_external_4
282
  self~assertSyntaxError(99.917, -
283
     "return 0", -
284
     "::class 'TestClass'", -
285
     "::attribute foo external 'library'")
286
287
::method test_external_5
288
  self~assertSyntaxError(98.903, -
289
     "return 0", -
290
     "::class 'TestClass'", -
291
     "::attribute foo external 'library mylib'")
292
293
::method test_external_6
294
  self~assertSyntaxError(90.998, -
295
     "return 0", -
296
     "::class 'TestClass'", -
297
     "::attribute foo external 'library rxsock'")
298
299
::method test_external_7
300
  self~assertSyntaxError(90.998, -
301
     "return 0", -
302
     "::class 'TestClass'", -
303
     "::attribute foo get external 'library rxsock'")
304
305
::method test_external_8
306
  self~assertSyntaxError(90.998, -
307
     "return 0", -
308
     "::class 'TestClass'", -
309
     "::attribute foo get external 'library rxsock whatever'")
310
311
::method test_external_9
312
  self~assertSyntaxError(90.998, -
313
     "return 0", -
314
     "::class 'TestClass'", -
315
     "::attribute foo external 'library rxsock whatever'")
316
317
::method test_external_10
318
  self~assertSyntaxError(90.998, -
319
     "return 0", -
320
     "::class 'TestClass'", -
321
     "::attribute foo set external 'library rxsock'")
322
323
::method test_external_11
324
  self~assertSyntaxError(90.998, -
325
     "return 0", -
326
     "::class 'TestClass'", -
327
     "::attribute foo set external 'library rxsock whatever'")
328
329
::method test_external_12
330
  self~assertSyntaxError(99.917, -
331
     "return 0", -
332
     "::class 'TestClass'", -
333
     "::attribute foo external 'library rxsock whatever junk'")
334
335
::method test_external_13
336
  self~assertSyntaxError(25.925, -
337
     "return 0", -
338
     "::class 'TestClass'", -
339
     "::attribute foo abstract external 'library rxsock whatever'")
340
341
::method test_external_14
342
  self~assertSyntaxError(25.925, -
343
     "return 0", -
344
     "::class 'TestClass'", -
345
     "::attribute foo external 'library rxsock whatever' abstract")
346
347
::method test_external_15
348
  self~assertSyntaxError(99.937, -
349
     "return 0", -
350
     "::class 'TestClass'", -
351
     "::attribute foo external 'library rxsock whatever'", -
352
     " return .false")
353
354
::method assertSyntaxError
355
  use arg syntax
356
357
  src = arg(2, 'array')
358
359
  self~expectSyntax(syntax)
360
  p = .Package~new("constant_TestGroup", src)
361
362
::class test mixinclass object
363
-- initialize some class variables for test usage
364
::method init class
365
  expose v1 v2 v3
366
  v1 = "Fred"
367
  v2 = "George"
368
  v3 = "Mike"
369
-- instance variables...same variable names, different scope
370
::method init
371
  expose v1 v2 v3
372
  v1 = "Rick"
373
  v2 = "David"
374
  v3 = "Mark"
375
376
-- instance and class versions of the attributes
377
::attribute v1 class guarded public protected
378
::attribute v1 unguarded public unprotected
379
380
::attribute v2 class get unguarded protected
381
::attribute v2 class set unguarded protected
382
  expose v2
383
  use strict arg v2
384
385
::attribute v2 get unguarded protected
386
::attribute v2 set unguarded protected
387
  expose v2
388
  use strict arg v2
389
390
::attribute v3 class get
391
  expose v3
392
  return v3
393
::attribute v3 class set
394
395
::attribute v3 get
396
  expose v3
397
  return v3
398
::attribute v3 set
399
400
-- these will be uninitialied initially
401
::attribute v4
402
::attribute v4 class
403
404
-- different abstract combos
405
406
::attribute v5 abstract
407
::attribute v5 class abstract
408
409
::attribute v6 abstract set
410
::attribute v6 class abstract set
411
-- non-abstract getters to show no effect on the other side
412
::attribute v6 get
413
::attribute v6 class get
414
415
::attribute v7 abstract get
416
::attribute v7 class abstract get
417
::attribute v7 set
418
::attribute v7 class set
419
420
-- private attribute tests...some methods are to demonstrate
421
-- that the method can be reached via private means
422
423
::attribute v8 private
424
::attribute v9 get private
425
::attribute v9 set
426
::attribute v10 set private
427
::attribute v10 get
428
429
::method v8get
430
  return self~v8
431
432
::method v8set
433
  use arg value
434
  self~v8 = value
435
436
::method v9get
437
  return self~v9
438
439
::method v10set
440
  use arg value
441
  self~v10 = value
442

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks