~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/tests/base/tests/base.html

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
 
<html>
3
 
<head>
4
 
    <title>Base Tests</title>
5
 
 
6
 
    <script src="../../../build/yui/yui.js"></script>
7
 
 
8
 
    <style type="text/css">
9
 
        #console .yui3-console-entry {
10
 
            padding:2px;
11
 
            margin:0px;
12
 
            min-height:0;
13
 
        }
14
 
 
15
 
        #console .yui3-console-entry-fail .yui3-console-entry-cat {
16
 
            background-color:red;
17
 
        }
18
 
 
19
 
        #console .yui3-console-entry-pass .yui3-console-entry-cat {
20
 
            background-color:green;
21
 
        }
22
 
 
23
 
        #console .yui3-console-entry-perf .yui3-console-entry-cat {
24
 
            background-color:blue;
25
 
        }
26
 
 
27
 
        #console {
28
 
            position:static;
29
 
        }
30
 
 
31
 
        html, body {
32
 
            height:100%;
33
 
        }
34
 
    </style>
35
 
</head>
36
 
<body class="yui3-skin-sam">
37
 
<div id="testbed" class="yui3-skin-foo"></div>
38
 
<script>
39
 
YUI({
40
 
    useBrowserConsole:false,
41
 
    filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min'
42
 
}).use('test', 'base', 'console', function (Y) {
43
 
 
44
 
    // NOTE: Attribute's unit tests cover a large section of Base's functionality when it comes to dealing with attributes.
45
 
 
46
 
    var suite = new Y.Test.Suite("Base Tests");
47
 
 
48
 
    suite.add(new Y.Test.Case({
49
 
 
50
 
        name : "BaseBuild",
51
 
 
52
 
        "test:create-basic": function () {
53
 
 
54
 
            var expectedMethodCalls = [
55
 
                "ext1::constructor", 
56
 
                "myClass::initializer",
57
 
                "ext1::constructor", 
58
 
                "myClass::initializer", 
59
 
                "myClass::methodOne",
60
 
                "myClass::methodOne",
61
 
                "ext1::extOne",
62
 
                "ext1::extOne"],
63
 
 
64
 
                actualMethodCalls = [];
65
 
 
66
 
            function Ext1() {
67
 
                actualMethodCalls.push("ext1::constructor");
68
 
            }
69
 
 
70
 
            Ext1.prototype.extOne = function() {
71
 
                actualMethodCalls.push("ext1::extOne");
72
 
            };
73
 
 
74
 
            var MyClass = Y.Base.create("myClass", Y.Base, [Ext1], {
75
 
                
76
 
                initializer: function() {
77
 
                    actualMethodCalls.push("myClass::initializer");
78
 
                },
79
 
 
80
 
                methodOne: function() {
81
 
                    actualMethodCalls.push("myClass::methodOne");
82
 
                }
83
 
 
84
 
            }, {
85
 
                STATIC_ONE: "static_one"
86
 
            });
87
 
 
88
 
            // using 2 instances, just to make sure nothing static/prototype related gets broken by the 1st instance
89
 
            var o1 = new MyClass({foo:true});
90
 
            var o2 = new MyClass({foo:true});
91
 
 
92
 
            Y.Assert.isFunction(o1.extOne, "Extension method extOne not found on o1");
93
 
            Y.Assert.isFunction(o2.extOne, "Extension method extOne not found on o2");
94
 
 
95
 
            Y.Assert.isFunction(o1.methodOne, "Prototype method methodOne not found on o1");
96
 
            Y.Assert.isFunction(o2.methodOne, "Prototype method methodOne not found on o2");
97
 
 
98
 
            Y.Assert.areEqual(o1.constructor.STATIC_ONE, "static_one", "STATIC_ONE not found on o1's constructor");
99
 
            Y.Assert.areEqual(o2.constructor.STATIC_ONE, "static_one", "STATIC_ONE not found on o2's constructor");
100
 
            
101
 
            Y.Assert.areEqual(o1.constructor.NAME, "myClass", "NAME not found on o1's constructor");
102
 
            Y.Assert.areEqual(o2.constructor.NAME, "myClass", "NAME not found on o2's constructor"); 
103
 
 
104
 
            o1.methodOne();
105
 
            o2.methodOne();
106
 
 
107
 
            o1.extOne();
108
 
            o2.extOne();
109
 
 
110
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
111
 
        },
112
 
 
113
 
        "test:mix-basic": function() {
114
 
 
115
 
            var expectedMethodCalls = [
116
 
                "myClass::constructor",
117
 
                "ext1::constructor",
118
 
                "myClass::initializer",
119
 
                "myClass::constructor",
120
 
                "ext1::constructor",
121
 
                "myClass::initializer", 
122
 
                "myClass::methodOne",
123
 
                "myClass::methodOne",
124
 
                "ext1::extOne",
125
 
                "ext1::extOne"],
126
 
 
127
 
                actualMethodCalls = [];
128
 
 
129
 
            function Ext1() {
130
 
                actualMethodCalls.push("ext1::constructor");
131
 
            }
132
 
 
133
 
            Ext1.prototype.extOne = function() {
134
 
                actualMethodCalls.push("ext1::extOne");
135
 
            };
136
 
 
137
 
            function MyClass(config) {
138
 
                actualMethodCalls.push("myClass::constructor");
139
 
                MyClass.superclass.constructor.apply(this, arguments);
140
 
            }
141
 
 
142
 
            Y.extend(MyClass, Y.Base, {
143
 
                
144
 
                initializer: function() {
145
 
                    actualMethodCalls.push("myClass::initializer");
146
 
                },
147
 
 
148
 
                methodOne: function() {
149
 
                    actualMethodCalls.push("myClass::methodOne");
150
 
                }
151
 
 
152
 
            }, {
153
 
                STATIC_ONE: "static_one",
154
 
                NAME: "myClass"
155
 
            });
156
 
 
157
 
            Y.Base.mix(MyClass, [Ext1]);             
158
 
 
159
 
            // using 2 instances, just to make sure nothing static/prototype related gets broken by the 1st instance
160
 
            var o1 = new MyClass();
161
 
            var o2 = new MyClass();
162
 
 
163
 
            Y.Assert.isFunction(o1.extOne, "Extension method extOne not found on o1");
164
 
            Y.Assert.isFunction(o2.extOne, "Extension method extOne not found on o2");
165
 
 
166
 
            Y.Assert.isFunction(o1.methodOne, "Prototype method methodOne not found on o1");
167
 
            Y.Assert.isFunction(o2.methodOne, "Prototype method methodOne not found on o2");
168
 
 
169
 
            Y.Assert.areEqual(o1.constructor.STATIC_ONE, "static_one", "STATIC_ONE not found on o1's constructor");
170
 
            Y.Assert.areEqual(o2.constructor.STATIC_ONE, "static_one", "STATIC_ONE not found on o2's constructor"); 
171
 
 
172
 
            o1.methodOne();
173
 
            o2.methodOne();
174
 
 
175
 
            o1.extOne();
176
 
            o2.extOne();
177
 
 
178
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
179
 
        },
180
 
 
181
 
        "test:initializer": function() {
182
 
            var expectedMethodCalls = [
183
 
                "ext1::constructor", 
184
 
                "myClass::initializer",
185
 
                "ext1::initializer", 
186
 
                "ext1::constructor", 
187
 
                "myClass::initializer",
188
 
                "ext1::initializer"],
189
 
 
190
 
                actualMethodCalls = [];
191
 
 
192
 
            function Ext1(cfg) {
193
 
                actualMethodCalls.push("ext1::constructor");
194
 
                Y.Assert.isNotUndefined(cfg);
195
 
            }
196
 
 
197
 
            Ext1.prototype.initializer = function(cfg) {
198
 
                actualMethodCalls.push("ext1::initializer");
199
 
                Y.Assert.isNotUndefined(cfg);
200
 
            };
201
 
 
202
 
            var MyClass = Y.Base.create("myClass", Y.Base, [Ext1], {
203
 
                initializer: function(cfg) {
204
 
                    actualMethodCalls.push("myClass::initializer");
205
 
                    Y.Assert.isNotUndefined(cfg);
206
 
                }
207
 
            });
208
 
 
209
 
            // using 2 instances, just to make sure nothing static/prototype related gets broken by the 1st instance
210
 
            var o1 = new MyClass({foo:true});
211
 
            var o2 = new MyClass({foo:true});
212
 
 
213
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
214
 
        },
215
 
        
216
 
        "test:destructor": function() {
217
 
            var expectedMethodCalls = [
218
 
                "ext1::destructor",
219
 
                "myClass::destructor",
220
 
                "ext1::destructor",
221
 
                "myClass::destructor"],
222
 
 
223
 
                actualMethodCalls = [];
224
 
 
225
 
            function Ext1(cfg) {}
226
 
 
227
 
            Ext1.prototype.destructor = function(cfg) {
228
 
                actualMethodCalls.push("ext1::destructor");
229
 
            };
230
 
 
231
 
            var MyClass = Y.Base.create("myClass", Y.Base, [Ext1], {
232
 
                destructor: function(cfg) {
233
 
                    actualMethodCalls.push("myClass::destructor");
234
 
                }
235
 
            });
236
 
 
237
 
            // using 2 instances, just to make sure nothing static/prototype related gets broken by the 1st instance
238
 
            var o1 = new MyClass({foo:true});
239
 
            var o2 = new MyClass({foo:true});
240
 
 
241
 
            o1.destroy();
242
 
            o2.destroy();
243
 
 
244
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
245
 
        },
246
 
 
247
 
        "test:attrs" : function() {
248
 
 
249
 
            var actualMethodCalls = [],
250
 
                expectedMethodCalls = [
251
 
                    "ext1::attr2::setter", // once for lazy o1 - This was news to me: we should optimize it as part off Attr performance
252
 
                    "ext1::attr2::setter", // once for set o1
253
 
                    "ext1::attr2::setter", // once for lazy o2
254
 
                    "ext1::attr2::setter"  // once for set o2
255
 
                ];
256
 
 
257
 
            function Ext1() {}
258
 
 
259
 
            Ext1.ATTRS = {
260
 
                attr1 : {
261
 
                    value:"attr1-ext1"
262
 
                },
263
 
                attr2 : {
264
 
                    value:"attr2-ext1",
265
 
                    setter: function(val) {
266
 
                        actualMethodCalls.push("ext1::attr2::setter");
267
 
                        return val;
268
 
                    }
269
 
                },
270
 
                attr3: {
271
 
                    value:"attr3-ext1"
272
 
                }
273
 
            };
274
 
 
275
 
            var MyClass = Y.Base.create("myClass", Y.Base, [Ext1]);
276
 
 
277
 
            // using 2 instances, just to make sure nothing static/prototype related gets broken by the 1st instance
278
 
            var o1 = new MyClass();
279
 
            var o2 = new MyClass();
280
 
            
281
 
            o1.set("attr2", "foo");
282
 
            o2.set("attr2", "foo");
283
 
 
284
 
            Y.Assert.areEqual("attr1-ext1", o1.get("attr1"), "o1 attr1 incorrect");
285
 
            Y.Assert.areEqual("attr1-ext1", o2.get("attr1"), "o2 attr1 incorrect");
286
 
            
287
 
            Y.Assert.areEqual("foo", o1.get("attr2"), "o1 attr2 incorrect");
288
 
            Y.Assert.areEqual("foo", o2.get("attr2"), "o2 attr2 incorrect");
289
 
            
290
 
            Y.Assert.areEqual("attr3-ext1", o1.get("attr3"), "o1 attr3 incorrect");
291
 
            Y.Assert.areEqual("attr3-ext1", o2.get("attr3"), "o2 attr3 incorrect");
292
 
 
293
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
294
 
        },
295
 
 
296
 
        "test:aggregates" : function() {
297
 
 
298
 
            function Ext1() {}
299
 
 
300
 
            Ext1.HTML_PARSER = {
301
 
                a:"aa",
302
 
                b:"bb"
303
 
            };
304
 
 
305
 
            function MyWidget(config) {
306
 
                MyWidget.superclass.constructor.apply(this, arguments);
307
 
            }
308
 
 
309
 
            Y.extend(MyWidget, Y.Base, {}, {
310
 
 
311
 
                HTML_PARSER : {
312
 
                    a:"a"
313
 
                },
314
 
 
315
 
                _buildCfg : {
316
 
                    aggregates : ["HTML_PARSER"]
317
 
                }
318
 
            });
319
 
 
320
 
            var MyClass = Y.Base.create("myClass", MyWidget, [Ext1]);
321
 
 
322
 
            // using 2 instances, just to make sure nothing static/prototype related gets broken by the 1st instance
323
 
            var o1 = new MyClass();
324
 
            var o2 = new MyClass();
325
 
 
326
 
            Y.ObjectAssert.areEqual({a:"aa", b:"bb"}, o1.constructor.HTML_PARSER, "o1 HTML_PARSER not aggregated correctly");
327
 
            Y.ObjectAssert.areEqual({a:"aa", b:"bb"}, o2.constructor.HTML_PARSER, "o2 HTML_PARSER not aggregated correctly");
328
 
 
329
 
        },
330
 
 
331
 
        "test:overrides-ext-wins" : function() {
332
 
 
333
 
            var actualMethodCalls = [],
334
 
                expectedMethodCalls = [
335
 
                    "ext1::attr2::setter", // once for lazy o1
336
 
                    "ext1::attr2::setter", // once for set o1
337
 
                    "ext1::attr2::setter", // once for lazy o2
338
 
                    "ext1::methodOne",
339
 
                    "ext1::methodOne"
340
 
                ];
341
 
 
342
 
            function Ext1() {}
343
 
 
344
 
            Ext1.prototype.methodOne = function() {
345
 
                actualMethodCalls.push("ext1::methodOne");
346
 
            };
347
 
 
348
 
            Ext1.ATTRS = {
349
 
                attr1 : {
350
 
                    value:"attr1-ext1"
351
 
                },
352
 
                attr2 : {
353
 
                    value:"attr2-ext1",
354
 
                    setter: function(val) {
355
 
                        actualMethodCalls.push("ext1::attr2::setter");
356
 
                        return val;
357
 
                    }
358
 
                },
359
 
                attr3: {
360
 
                    value:"attr3-ext1"
361
 
                }
362
 
            };
363
 
 
364
 
            function MyClass() {
365
 
                MyClass.superclass.constructor.apply(this, arguments);
366
 
            }
367
 
            
368
 
            MyClass.NAME = "myClass";
369
 
 
370
 
            MyClass.ATTRS = {
371
 
                attr1 : {
372
 
                    value:"attr1-myClass"
373
 
                },
374
 
                attr2 : {
375
 
                    value:"attr2-myClass",
376
 
                    setter: function(val) {
377
 
                        actualMethodCalls.push("myClass::attr2::setter");
378
 
                        return val;
379
 
                    }
380
 
                },
381
 
                attr4 : {
382
 
                    value:"attr4-myClass"
383
 
                }
384
 
            };
385
 
 
386
 
            Y.extend(MyClass, Y.Base, {
387
 
                methodOne : function() {
388
 
                    actualMethodCalls.push("myClass::methodOne");
389
 
                }
390
 
            });
391
 
            Y.Base.mix(MyClass, [Ext1]);
392
 
 
393
 
            // using 2 instances, just to make sure nothing static/prototype related gets broken by the 1st instance
394
 
            var o1 = new MyClass();
395
 
            var o2 = new MyClass();
396
 
 
397
 
            // only set o1
398
 
            o1.set("attr2", "foo");
399
 
 
400
 
            Y.Assert.areEqual("attr1-ext1", o1.get("attr1"), "o1 attr1 incorrect");
401
 
            Y.Assert.areEqual("attr1-ext1", o2.get("attr1"), "o2 attr1 incorrect");
402
 
 
403
 
            Y.Assert.areEqual("foo", o1.get("attr2"), "o1 attr2 incorrect");
404
 
            Y.Assert.areEqual("attr2-ext1", o2.get("attr2"), "o2 attr2 incorrect");
405
 
            
406
 
            Y.Assert.areEqual("attr3-ext1", o1.get("attr3"), "o1 attr3 incorrect");
407
 
            Y.Assert.areEqual("attr3-ext1", o2.get("attr3"), "o2 attr3 incorrect");
408
 
 
409
 
            Y.Assert.areEqual("attr4-myClass", o1.get("attr4"), "o1 attr4 incorrect");
410
 
            Y.Assert.areEqual("attr4-myClass", o2.get("attr4"), "o2 attr4 incorrect");
411
 
 
412
 
            o1.methodOne();
413
 
            o2.methodOne();
414
 
 
415
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
416
 
        },
417
 
 
418
 
        "test:overrides-host-wins" : function() {
419
 
 
420
 
            var actualMethodCalls = [],
421
 
                expectedMethodCalls = [
422
 
                    "myClass::attr2::setter", // once for lazy o1
423
 
                    "myClass::attr2::setter", // once for set o1
424
 
                    "myClass::attr2::setter", // once for lazy o2
425
 
                    "myClass::methodOne",
426
 
                    "myClass::methodOne"
427
 
                ];
428
 
 
429
 
            function Ext1() {}
430
 
            
431
 
            Ext1.prototype.methodOne = function() {
432
 
                actualMethodCalls.push("ext1::methodOne");
433
 
            };
434
 
 
435
 
            Ext1.ATTRS = {
436
 
                attr1 : {
437
 
                    value:"attr1-ext1"
438
 
                },
439
 
                attr2 : {
440
 
                    value:"attr2-ext1",
441
 
                    setter: function(val) {
442
 
                        actualMethodCalls.push("ext1::attr2::setter");
443
 
                        return val;
444
 
                    }
445
 
                },
446
 
                attr3: {
447
 
                    value:"attr3-ext1"
448
 
                }
449
 
            };
450
 
 
451
 
            var MyClass = Y.Base.create("myClass", Y.Base, [Ext1], {
452
 
                methodOne : function() {
453
 
                    actualMethodCalls.push("myClass::methodOne");
454
 
                }
455
 
            }, { 
456
 
                ATTRS : {
457
 
                    attr1 : {
458
 
                        value:"attr1-myClass"
459
 
                    },
460
 
                    attr2 : {
461
 
                        value:"attr2-myClass",
462
 
                        setter: function(val) {
463
 
                            actualMethodCalls.push("myClass::attr2::setter");
464
 
                            return val;
465
 
                        }
466
 
                    },
467
 
                    attr4 : {
468
 
                        value:"attr4-myClass"
469
 
                    }
470
 
                }
471
 
            });
472
 
 
473
 
            // Using 2 instances, just to make sure nothing static/prototype related gets broken by the 1st instance
474
 
            var o1 = new MyClass();
475
 
            var o2 = new MyClass();
476
 
 
477
 
            // only set o1
478
 
            o1.set("attr2", "foo");
479
 
 
480
 
            Y.Assert.areEqual("attr1-myClass", o1.get("attr1"), "o1 attr1 incorrect");
481
 
            Y.Assert.areEqual("attr1-myClass", o2.get("attr1"), "o2 attr1 incorrect");
482
 
 
483
 
            Y.Assert.areEqual("foo", o1.get("attr2"), "o1 attr2 incorrect");
484
 
            Y.Assert.areEqual("attr2-myClass", o2.get("attr2"), "o2 attr2 incorrect");
485
 
 
486
 
            Y.Assert.areEqual("attr3-ext1", o1.get("attr3"), "o1 attr3 incorrect");
487
 
            Y.Assert.areEqual("attr3-ext1", o2.get("attr3"), "o2 attr3 incorrect");
488
 
 
489
 
            Y.Assert.areEqual("attr4-myClass", o1.get("attr4"), "o1 attr4 incorrect");
490
 
            Y.Assert.areEqual("attr4-myClass", o2.get("attr4"), "o2 attr4 incorrect");
491
 
 
492
 
            o1.methodOne();
493
 
            o2.methodOne();
494
 
 
495
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
496
 
        },
497
 
 
498
 
        "test:multiext-complex" : function() {
499
 
 
500
 
            var actualMethodCalls = [],
501
 
                expectedMethodCalls = [
502
 
                    "ext1::constructor",
503
 
                    "ext2::constructor", 
504
 
                    "myClass::initializer",
505
 
                    "ext1::initializer",
506
 
                    "ext2::initializer",
507
 
                    "ext1::constructor",
508
 
                    "ext2::constructor", 
509
 
                    "myClass::initializer",
510
 
                    "ext1::initializer",
511
 
                    "ext2::initializer",
512
 
                    "ext2::attr3::setter",
513
 
                    "ext2::attr3::setter",
514
 
                    "myClass::methodOne",
515
 
                    "myClass::methodOne",
516
 
                    "myClass::methodTwo",
517
 
                    "myClass::methodTwo",
518
 
                    "ext2::methodThree",
519
 
                    "ext2::methodThree",
520
 
                    "ext2::methodFour",
521
 
                    "ext2::methodFour",
522
 
                    "myClass::methodFive",
523
 
                    "myClass::methodFive"
524
 
                ];
525
 
 
526
 
            function Ext1() {
527
 
                actualMethodCalls.push("ext1::constructor");
528
 
            }
529
 
 
530
 
            Ext1.prototype.initializer = function() {
531
 
                actualMethodCalls.push("ext1::initializer");
532
 
            };
533
 
 
534
 
            Ext1.prototype.methodTwo = function() {
535
 
                actualMethodCalls.push("ext1::methodTwo");
536
 
            };
537
 
 
538
 
            Ext1.prototype.methodThree = function() {
539
 
                actualMethodCalls.push("ext1::methodThree");
540
 
            };
541
 
 
542
 
            Ext1.ATTRS = {
543
 
                attr2 : {
544
 
                    value:"ext1-attr2"
545
 
                },
546
 
                attr3 : {
547
 
                    value:"ext1-attr3",
548
 
                    setter: function(val) {
549
 
                        actualMethodCalls.push("ext1::attr3::setter");
550
 
                        return val;
551
 
                    }
552
 
                },
553
 
                attr4: {
554
 
                    value:"ext1-attr4"
555
 
                }
556
 
            };
557
 
 
558
 
            function Ext2() {
559
 
                actualMethodCalls.push("ext2::constructor");
560
 
            }
561
 
 
562
 
            Ext2.prototype.initializer = function() {
563
 
                actualMethodCalls.push("ext2::initializer");
564
 
            };
565
 
 
566
 
            Ext2.prototype.methodThree = function() {
567
 
                actualMethodCalls.push("ext2::methodThree");
568
 
            };
569
 
 
570
 
            Ext2.prototype.methodFour = function() {
571
 
                actualMethodCalls.push("ext2::methodFour");
572
 
            };
573
 
 
574
 
            Ext2.ATTRS = {
575
 
                attr3 : {
576
 
                    value:"ext2-attr3",
577
 
                    setter: function(val) {
578
 
                        actualMethodCalls.push("ext2::attr3::setter");
579
 
                        return val;
580
 
                    }
581
 
                },
582
 
                attr4 : {
583
 
                    value:"ext2-attr4"
584
 
                }
585
 
            };
586
 
 
587
 
            var MyClass = Y.Base.create("myClass", Y.Base, [Ext1, Ext2], {
588
 
                
589
 
                initializer: function() {
590
 
                    actualMethodCalls.push("myClass::initializer");
591
 
                },
592
 
                
593
 
                methodOne : function() {
594
 
                    actualMethodCalls.push("myClass::methodOne");
595
 
                },
596
 
                
597
 
                methodTwo : function() {
598
 
                    actualMethodCalls.push("myClass::methodTwo");
599
 
                },
600
 
 
601
 
                methodFive : function() {
602
 
                    actualMethodCalls.push("myClass::methodFive");
603
 
                }
604
 
            }, { 
605
 
                ATTRS : {
606
 
                    attr1 : {
607
 
                        value:"myClass-attr1"
608
 
                    },
609
 
                    attr5 : {
610
 
                        value:"myClass-attr5"
611
 
                    }
612
 
                }
613
 
            });
614
 
            
615
 
            var o1 = new MyClass();
616
 
            var o2 = new MyClass();
617
 
            
618
 
            Y.Assert.areEqual("myClass-attr1", o1.get("attr1"), "o1 attr1 incorrect");
619
 
            Y.Assert.areEqual("myClass-attr1", o2.get("attr1"), "o2 attr1 incorrect");
620
 
 
621
 
            Y.Assert.areEqual("ext1-attr2", o1.get("attr2"), "o1 attr2 incorrect");
622
 
            Y.Assert.areEqual("ext1-attr2", o2.get("attr2"), "o2 attr2 incorrect");
623
 
 
624
 
            Y.Assert.areEqual("ext2-attr3", o1.get("attr3"), "o1 attr3 incorrect");
625
 
            Y.Assert.areEqual("ext2-attr3", o2.get("attr3"), "o2 attr3 incorrect");
626
 
 
627
 
            Y.Assert.areEqual("ext2-attr4", o1.get("attr4"), "o1 attr4 incorrect");
628
 
            Y.Assert.areEqual("ext2-attr4", o2.get("attr4"), "o2 attr4 incorrect");
629
 
 
630
 
            Y.Assert.areEqual("myClass-attr5", o1.get("attr5"), "o1 attr5 incorrect");
631
 
            Y.Assert.areEqual("myClass-attr5", o2.get("attr5"), "o2 attr5 incorrect");
632
 
 
633
 
            o1.methodOne();
634
 
            o2.methodOne();
635
 
            o1.methodTwo();
636
 
            o2.methodTwo();
637
 
            o1.methodThree();
638
 
            o2.methodThree();
639
 
            o1.methodFour();
640
 
            o2.methodFour();
641
 
            o1.methodFive();
642
 
            o2.methodFive();
643
 
            
644
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
645
 
        },
646
 
        
647
 
        "test:classstructure" : function() {
648
 
            function Ext1() {}
649
 
            Ext1.prototype.extOne = function() {};
650
 
 
651
 
            function Ext2() {}
652
 
            Ext2.prototype.extTwo = function() {};
653
 
 
654
 
            var MyClassTwo = Y.Base.create("myClassTwo", Y.Base, [Ext1, Ext2], {
655
 
                initializer: function() {},
656
 
                methodOne: function() {}
657
 
            });
658
 
 
659
 
            var MyClassOne = Y.Base.create("myClassOne", Y.Base, [Ext1], {
660
 
                initializer: function() {},
661
 
                methodOne: function() {}
662
 
            });
663
 
            
664
 
            var o1 = new MyClassOne();
665
 
            var o2 = new MyClassTwo();
666
 
 
667
 
            Y.Assert.isTrue(o1.hasImpl(Ext1), "o1 should pass hasImpl(Ext1)");
668
 
            Y.Assert.isFalse(o1.hasImpl(Ext2),  "o1 should fail hasImpl(Ext2)");
669
 
 
670
 
            Y.Assert.isTrue(o2.hasImpl(Ext1),  "o2 should pass hasImpl(Ext1)");
671
 
            Y.Assert.isTrue(o2.hasImpl(Ext2), "o2 should pass hasImpl(Ext1)");
672
 
            
673
 
            Y.Assert.isTrue(o1 instanceof MyClassOne, "o1 should be an instanceof MyClassOne");
674
 
            Y.Assert.isTrue(o1 instanceof Y.Base, "o1 should be an instanceof Base");
675
 
            
676
 
            Y.Assert.isTrue(o2 instanceof MyClassTwo, "o2 should be an instanceof MyClassTwo");
677
 
            Y.Assert.isTrue(o2 instanceof Y.Base, "o2 should be an instanceof Base");
678
 
 
679
 
            Y.Assert.isFalse(o1 instanceof MyClassTwo, "o1 should NOT be an instanceof MyClassTwo");
680
 
            Y.Assert.isFalse(o2 instanceof MyClassOne, "o2 should NOT be an instanceof MyClassOne");
681
 
            
682
 
            Y.Assert.isFunction(o1.methodOne, "o1 should have a methodOne method");
683
 
            Y.Assert.isFunction(o1.extOne, "o1 should have an extOne method");
684
 
            Y.Assert.isUndefined(o1.extTwo, "o1 should not have an extTwo method");
685
 
 
686
 
            Y.Assert.isFunction(o2.methodOne, "o2 should have a methodOne method");
687
 
            Y.Assert.isFunction(o2.extOne, "o2 should have an extOne method");
688
 
            Y.Assert.isFunction(o2.extTwo, "o2 should have an extTwo method");
689
 
 
690
 
            Y.Assert.isTrue(MyClassOne.superclass.constructor === Y.Base, "MyClassOne should have superclass set to Base");
691
 
            Y.Assert.isTrue(MyClassTwo.superclass.constructor === Y.Base, "MyClassTwo should have superclass set to Base");
692
 
 
693
 
            // Make sure Y.Base was untouched.
694
 
            var b = new Y.Base();
695
 
 
696
 
            Y.Assert.isUndefined(b.methodOne, "Base should not have extension methods");
697
 
            Y.Assert.isUndefined(b.extOne, "Base should not have extension methods");
698
 
            Y.Assert.isUndefined(b.extTwo, "Base should not have extension methods");
699
 
            Y.Assert.isFalse(MyClassOne === Y.Base);
700
 
            Y.Assert.isFalse(MyClassTwo === Y.Base);
701
 
        },
702
 
 
703
 
        "test:extend" : function() {
704
 
            
705
 
            var actualMethodCalls = [],
706
 
                expectedMethodCalls = [
707
 
                    "ext1::constructor",
708
 
                    "myClassOne::initializer",
709
 
                    "ext1::initializer",
710
 
                    "ext2::constructor",
711
 
                    "myClassTwo::initializer",
712
 
                    "ext2::initializer",
713
 
                    "myClassOne::methodOne",
714
 
                    "myClassTwo::methodTwo",
715
 
                    "ext1::extOne",
716
 
                    "ext2::extTwo"
717
 
                ];
718
 
 
719
 
            function Ext1() {
720
 
                actualMethodCalls.push("ext1::constructor");                
721
 
            }
722
 
            Ext1.prototype.extOne = function() {
723
 
                actualMethodCalls.push("ext1::extOne");
724
 
            };
725
 
            Ext1.prototype.initializer = function() {
726
 
                actualMethodCalls.push("ext1::initializer");
727
 
            };
728
 
 
729
 
            function Ext2() {
730
 
                actualMethodCalls.push("ext2::constructor");
731
 
            }
732
 
            Ext2.prototype.extTwo = function() {
733
 
                actualMethodCalls.push("ext2::extTwo");
734
 
            };
735
 
            Ext2.prototype.initializer = function() {
736
 
                actualMethodCalls.push("ext2::initializer");
737
 
            };
738
 
 
739
 
            var MyClassOne = Y.Base.create("myClassOne", Y.Base, [Ext1], {
740
 
                initializer: function() {
741
 
                    actualMethodCalls.push("myClassOne::initializer");    
742
 
                },
743
 
                methodOne: function() {
744
 
                    actualMethodCalls.push("myClassOne::methodOne");
745
 
                }
746
 
            });
747
 
 
748
 
            var MyClassTwo = Y.Base.create("myClassTwo", MyClassOne, [Ext2], {
749
 
                initializer: function() {
750
 
                    actualMethodCalls.push("myClassTwo::initializer");
751
 
                },
752
 
                methodTwo: function() {
753
 
                    actualMethodCalls.push("myClassTwo::methodTwo");
754
 
                }
755
 
            });
756
 
 
757
 
            var o = new MyClassTwo();
758
 
            o.methodOne();
759
 
            o.methodTwo();
760
 
            o.extOne();
761
 
            o.extTwo();
762
 
 
763
 
            Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
764
 
        }
765
 
 
766
 
    }));
767
 
 
768
 
    Y.Test.Runner.setName("Base Tests");
769
 
    Y.Test.Runner.add(suite);
770
 
    Y.Test.Runner.disableLogging();
771
 
    Y.Test.Runner.run();
772
 
 
773
 
    var console;
774
 
 
775
 
    Y.one("#btnRun").set("disabled", false).on("click", function() {
776
 
        if (!console) {
777
 
            console = new Y.Console({
778
 
                id:"console",
779
 
                width:"100%",
780
 
                height:"90%",
781
 
                verbose : false,
782
 
                printTimeout: 0,
783
 
                newestOnTop : false,
784
 
                entryTemplate: '<pre class="{entry_class} {cat_class} {src_class}">'+
785
 
                        '<span class="{entry_cat_class}">{label}</span>'+
786
 
                        '<span class="{entry_content_class}">{message}</span>'+
787
 
                '</pre>'
788
 
            }).render();
789
 
        }
790
 
 
791
 
        Y.Test.Runner.enableLogging();
792
 
        Y.Test.Runner.run();
793
 
    });
794
 
});
795
 
</script>
796
 
<p><input type="button" value="Run Tests" id="btnRun" disabled=true></p>
797
 
</body>
798
 
</html>