1
YUI.add('oop-test', function (Y) {
4
ArrayAssert = Y.ArrayAssert,
5
ObjectAssert = Y.ObjectAssert,
7
suite = new Y.Test.Suite('oop');
9
suite.add(new Y.Test.Case({
12
test_clone: function () {
21
Assert.isTrue((a.T === 'blabber'));
39
Assert.isTrue((d.a === 1));
40
Assert.isTrue((d.c() === 3));
44
test_clone_node: function () {
46
node: Y.one(document.createElement('div')),
50
el: document.createElement('div')
56
Assert.isFalse(b.node.foo === a.node.foo);
59
test_each: function () {
62
Y.each(null, function(v, k) {
66
Y.each('string', function(v, k) {
70
Y.each(12345, function(v, k) {
74
Y.each({ foo: 1 }, function(v, k) {
78
Assert.areEqual(1, count);
81
test_extend: function () {
82
var firedbase = false;
83
var firedextended = false;
85
var Base = function() {
86
arguments.callee.superclass.constructor.apply(this, arguments);
88
// bind by string in order to allow the subclass
89
this.on('testStringFn', Y.bind('base', this));
92
Y.extend(Base, Y.EventTarget, {
98
var Extended = function() {
99
arguments.callee.superclass.constructor.apply(this, arguments);
102
Y.extend(Extended, Base, {
104
firedextended = true;
108
var b = new Extended();
109
b.fire('testStringFn', 1, 2);
111
Y.Assert.isFalse(firedbase);
112
Y.Assert.isTrue(firedextended);
115
test_merge: function () {
116
Object.prototype.foo = 'hello!';
118
var o1 = { one: "one" },
120
o3 = { two: "twofromthree", three: "three" },
121
o4 = { one: "one", two: "twofromthree", three: "three" },
122
o123 = Y.merge(o1, o2, o3);
124
Y.ObjectAssert.areEqual(o123, o4);
125
Assert.areEqual(o123.two, o4.two);
127
Y.Assert.isFalse((o123.hasOwnProperty('foo')), 'prototype properties added to Object should not be iterable');
128
delete Object.prototype.foo;
132
suite.add(new Y.Test.Case({
136
this.receiver = function () {};
137
this.supplier = function () {};
140
tearDown: function () {
141
delete this.receiver;
142
delete this.supplier;
145
"receiver object should be augmented with supplier's prototype properties": function () {
147
supplier = this.supplier;
149
supplier.prototype.foo = 'foo';
150
supplier.prototype.bar = function () { return 'bar'; };
152
Assert.areSame(receiver, Y.augment(receiver, supplier));
153
Assert.areSame(2, Y.Object.size(receiver));
154
ArrayAssert.itemsAreSame(['foo', 'bar'], Y.Object.keys(receiver));
155
ArrayAssert.itemsAreSame(['foo', supplier.prototype.bar], Y.Object.values(receiver));
158
"receiver object properties should not be overwritten when `overwrite` is not `true`": function () {
159
var receiver = {foo: 'moo'},
160
supplier = this.supplier;
162
supplier.prototype.foo = 'foo';
163
supplier.prototype.bar = 'bar';
165
Y.augment(receiver, supplier);
167
Assert.areSame('moo', receiver.foo);
168
Assert.areSame('bar', receiver.bar);
171
"receiver object properties should be overwritten when `overwrite` is `true`": function () {
172
var receiver = {foo: 'moo'},
173
supplier = this.supplier;
175
supplier.prototype.foo = 'foo';
176
supplier.prototype.bar = 'bar';
178
Y.augment(receiver, supplier, true);
180
Assert.areSame('foo', receiver.foo);
181
Assert.areSame('bar', receiver.bar);
184
"only whitelisted properties should be copied to a receiver object": function () {
186
supplier = this.supplier;
188
supplier.prototype.foo = 'a';
189
supplier.prototype.bar = 'b';
190
supplier.prototype.baz = 'c';
192
Y.augment(receiver, supplier, false, ['foo', 'baz']);
194
ArrayAssert.itemsAreSame(['foo', 'baz'], Y.Object.keys(receiver));
197
"supplier constructor should be called immediately when augmenting a receiver object": function () {
201
function supplier() { calls += 1; }
203
Y.augment(receiver, supplier);
204
Assert.areSame(1, calls);
207
"supplier constructor should receive supplied args when augmenting a receiver object": function () {
211
function supplier(foo) {
213
Assert.areSame('foo', foo);
216
function supplierTwo(foo, bar) {
218
Assert.areSame('foo', foo);
219
Assert.areSame('bar', bar);
222
Y.augment(receiver, supplier, false, null, 'foo');
225
Y.augment(receiver, supplierTwo, false, null, ['foo', 'bar']);
227
Assert.areSame(2, calls);
230
"receiver function prototype should be augmented with supplier's prototype properties": function () {
231
var receiverCalls = 0,
235
function receiver() { receiverCalls += 1; }
236
function supplier() { supplierCalls += 1; }
238
supplier.prototype.foo = 'foo';
239
supplier.prototype.bar = function () { return 'bar'; };
240
supplier.prototype.baz = function () { return 'baz'; };
242
Assert.areSame(receiver, Y.augment(receiver, supplier));
243
ArrayAssert.itemsAreSame(['foo', 'bar', 'baz'], Y.Object.keys(receiver.prototype));
244
Assert.areSame('foo', receiver.prototype.foo);
245
Assert.areNotSame(supplier.prototype.bar, receiver.prototype.bar, '`bar()` should be sequestered on `receiver.prototype`');
246
Assert.areNotSame(supplier.prototype.baz, receiver.prototype.baz, '`baz()` should be sequestered on `receiver.prototype`');
247
Assert.isFunction(receiver.prototype.bar);
248
Assert.isFunction(receiver.prototype.baz);
250
instance = new receiver();
251
Assert.areSame(1, receiverCalls, "receiver's constructor should be called once");
252
Assert.areSame(0, supplierCalls, "supplier's constructor should not be called yet");
254
Assert.areNotSame(supplier.prototype.bar, instance.bar, '`bar()` should be sequestered on a new instance of `receiver`');
255
Assert.areNotSame(supplier.prototype.baz, instance.baz, '`baz()` should be sequestered on a new instance of `receiver`');
256
Assert.isFunction(instance.bar);
257
Assert.isFunction(instance.baz);
258
Assert.areSame('bar', instance.bar(), 'calling `bar()` on a new instance of `receiver` should work');
259
Assert.areSame(1, supplierCalls, "supplier's constructor should be called on first use of a sequestered function");
260
Assert.areSame(supplier.prototype.bar, instance.bar, 'after the first call, `instance.bar` and `supplier.prototype.bar` should be the same');
261
Assert.areSame(supplier.prototype.baz, instance.baz, 'after the first call, `instance.baz` and `supplier.prototype.baz` should be the same');
262
Assert.areSame('baz', instance.baz());
263
Assert.areSame(1, supplierCalls, "supplier's constructor should not be called twice");
266
"receiver function prototype properties should not be overwritten when `overwrite` is not `true`": function () {
267
var receiver = this.receiver,
268
supplier = this.supplier;
272
receiver.prototype.foo = 'moo';
273
receiver.prototype.quux = quux;
275
supplier.prototype.foo = 'foo';
276
supplier.prototype.bar = 'bar';
277
supplier.prototype.quux = function () {};
279
Y.augment(receiver, supplier);
281
Assert.areSame('moo', receiver.prototype.foo);
282
Assert.areSame('bar', receiver.prototype.bar);
283
Assert.areSame(quux, receiver.prototype.quux);
286
"receiver function prototype properties should be overwritten when `overwrite` is `true`": function () {
287
var receiver = this.receiver,
288
supplier = this.supplier;
292
receiver.prototype.foo = 'moo';
293
receiver.prototype.quux = quux;
295
supplier.prototype.foo = 'foo';
296
supplier.prototype.bar = 'bar';
297
supplier.prototype.quux = function () {};
299
Y.augment(receiver, supplier, true);
301
Assert.areSame('foo', receiver.prototype.foo);
302
Assert.areSame('bar', receiver.prototype.bar);
303
Assert.areNotSame(quux, receiver.prototype.quux);
306
"only whitelisted properties should be copied to a receiver function": function () {
307
var receiver = this.receiver,
308
supplier = this.supplier;
310
supplier.prototype.foo = 'a';
311
supplier.prototype.bar = 'b';
312
supplier.prototype.baz = 'c';
314
Y.augment(receiver, supplier, false, ['foo', 'baz']);
316
ArrayAssert.itemsAreSame(['foo', 'baz'], Y.Object.keys(receiver.prototype));
319
"supplier constructor should receive supplied args when augmenting a receiver function": function () {
321
receiver = function () {};
323
function supplier(foo) {
325
Assert.areSame('foo', foo);
328
function supplierTwo(foo, bar) {
330
Assert.areSame('foo', foo);
331
Assert.areSame('bar', bar);
334
supplier.prototype.foo = function () {};
335
supplierTwo.prototype.foo = function () {};
337
Y.augment(receiver, supplier, false, null, 'foo');
338
new receiver().foo();
340
receiver = function () {};
341
Y.augment(receiver, supplierTwo, false, null, ['foo', 'bar']);
342
new receiver().foo();
344
Assert.areSame(2, calls);
347
// http://yuilibrary.com/projects/yui3/ticket/2530501
348
'augmenting a Y.Node instance should not overwrite existing properties by default': function () {
349
var node = Y.one('#test');
351
Assert.isInstanceOf(Y.Node, node.get('parentNode'), 'parentNode attribute should be a Node instance before augment');
352
Y.augment(node, Y.Attribute);
353
Assert.isInstanceOf(Y.Node, node.get('parentNode'), 'parentNode attribute should be a Node instance after augment');
357
// TODO: mix tests should be moved to the tests for yui-core.js, where mix()
358
// lives now. Need to refactor yui-core tests first though.
360
suite.add(new Y.Test.Case({
361
name: 'mix: default mode (object to object)',
364
Object.prototype.foo = "I'm on Object.prototype!";
365
Object.prototype.zoo = "I'm on Object.prototype!";
368
tearDown: function () {
369
delete Object.prototype.foo;
370
delete Object.prototype.zoo;
373
'test [mode 0]: missing receiver or supplier': function () {
374
var receiver = {a: 'a'},
377
Assert.areSame(receiver, Y.mix(receiver), 'returns receiver when no supplier is passed');
378
Assert.areSame(Y, Y.mix(null, supplier), 'returns Y when no receiver is passed');
379
Assert.areSame(Y, Y.mix(), 'returns Y when neither receiver nor supplier is passed');
382
'test [mode 0]: returns receiver': function () {
383
var receiver = {a: 'a'},
386
Assert.areSame(receiver, Y.mix(receiver, supplier));
389
'test [mode 0]: no overwrite, no whitelist, no merge': function () {
390
var receiver = {a: 'a'},
391
supplier = {a: 'z', foo: 'foo', bar: 'bar', toString: function () {}};
393
Y.mix(receiver, supplier);
395
Assert.areSame(2, Y.Object.size(receiver), 'should own two keys');
396
ObjectAssert.ownsKeys(['a', 'bar'], receiver, 'should own new keys');
397
Assert.areSame('a', receiver.a, '"a" should not be overwritten');
400
Y.mix(receiver, Y.Object(supplier));
402
Assert.areSame(0, Y.Object.size(receiver), 'prototype properties should not get mixed');
405
'test [mode 0]: overwrite, no whitelist, no merge': function () {
406
var receiver = {a: 'a', obj: {a: 'a', b: 'b'}},
407
supplier = {a: 'z', foo: 'foo', bar: 'bar', obj: {a: 'z'}, toString: function () {}};
409
Y.mix(receiver, supplier, true);
411
Assert.areSame(5, Y.Object.size(receiver), 'should own five keys');
412
ObjectAssert.ownsKeys(['a', 'foo', 'bar', 'obj', 'toString'], receiver, 'should own new keys');
413
Assert.areSame('z', receiver.a, '"a" should be overwritten');
414
Assert.areSame(receiver.obj, supplier.obj, 'objects should be overwritten, not merged');
415
Assert.areSame(supplier.toString, receiver.toString, '"toString" should be the same');
418
'test [mode 0]: overwrite, whitelist, no merge': function () {
419
var receiver = {a: 'a', bar: 'a', obj: {a: 'a', b: 'b'}},
420
supplier = {a: 'z', foo: 'foo', bar: 'bar', obj: {a: 'z'}};
422
Y.mix(receiver, supplier, true, ['a', 'obj']);
424
Assert.areSame(3, Y.Object.size(receiver), 'should own three keys');
425
ObjectAssert.ownsKeys(['a', 'bar', 'obj'], receiver, 'should own whitelisted keys');
426
Assert.areSame('z', receiver.a, '"a" should be overwritten');
427
Assert.areSame('a', receiver.bar, '"bar" should not be overwritten');
428
Assert.areSame(receiver.obj, supplier.obj, 'objects should be overwritten, not merged');
431
'test [mode 0]: no overwrite, whitelist, no merge': function () {
432
var receiver = {a: 'a', bar: 'a', obj: {a: 'a', b: 'b'}},
433
supplier = {a: 'z', foo: 'foo', moo: 'cow', bar: 'bar', obj: {a: 'z'}};
435
Y.mix(receiver, supplier, false, ['a', 'obj', 'foo']);
437
Assert.areSame(3, Y.Object.size(receiver), 'should own three keys');
438
ObjectAssert.ownsKeys(['a', 'bar', 'obj'], receiver, 'should own whitelisted keys');
439
Assert.areSame('a', receiver.a, '"a" should not be overwritten');
440
Assert.areNotSame(receiver.obj, supplier.obj, '"obj" should not be overwritten');
441
Assert.areSame('a', receiver.obj.a, '"obj" should not be merged');
444
'test [mode 0]: no overwrite, no whitelist, merge': function () {
445
var receiver = {a: 'a', fakeout: {a: 'a'}, obj: {a: 'a', b: 'b', deep: {foo: 'foo', deeper: {bar: 'bar'}}}},
446
supplier = {a: 'z', foo: 'foo', bar: 'bar', fakeout: 'moo', obj: {a: 'z', deep: {deeper: {bar: 'z', baz: 'baz'}}}};
448
Y.mix(receiver, supplier, false, null, 0, true);
450
Assert.areSame(4, Y.Object.size(receiver), 'should own four keys');
451
ObjectAssert.ownsKeys(['a', 'bar', 'fakeout', 'obj'], receiver, 'should own new keys');
452
Assert.areSame('a', receiver.a, '"a" should not be overwritten');
453
Assert.areSame(1, Y.Object.size(receiver.fakeout), 'non-objects should not be merged into objects');
455
Assert.areNotSame(receiver.obj, supplier.obj, 'objects should be merged, not overwritten');
456
Assert.areNotSame(receiver.obj.deep, supplier.obj.deep, 'deep objects should be merged, not overwritten');
457
Assert.areNotSame(receiver.obj.deep.deeper, supplier.obj.deep.deeper, 'deeper objects should be merged, not overwritten');
459
Assert.areSame('a', receiver.obj.a, 'merged properties should not be overwritten');
460
Assert.areSame('b', receiver.obj.b, 'objects should be merged');
461
Assert.areSame('foo', receiver.obj.deep.foo, 'deep objects should be merged');
462
Assert.areSame('bar', receiver.obj.deep.deeper.bar, 'deeper merged properties should not be overwritten');
463
Assert.areSame('baz', receiver.obj.deep.deeper.baz, 'deeper objects should be merged');
465
// Array merge (see http://yuilibrary.com/projects/yui3/ticket/2528405)
466
receiver = {a: [{x: 1}, {x: 2}]};
467
supplier = {a: [{y: 99}, {y: 98}]};
469
Y.mix(receiver, supplier, false, null, 0, true);
471
Assert.areSame(1, receiver.a[0].x, 'objects in arrays should be merged');
472
Assert.areSame(99, receiver.a[0].y, 'objects in arrays should be merged');
475
'test [mode 0]: overwrite, no whitelist, merge': function () {
476
var receiver = {a: 'a', obj: {a: 'a', b: 'b', deep: {foo: 'foo', deeper: {bar: 'bar'}}}},
477
supplier = {a: 'z', foo: 'foo', bar: 'bar', obj: {a: 'z', deep: {deeper: {bar: 'z'}}}};
479
Y.mix(receiver, supplier, true, null, 0, true);
481
Assert.areSame(4, Y.Object.size(receiver), 'should own four keys');
482
ObjectAssert.ownsKeys(['a', 'foo', 'bar', 'obj'], receiver, 'should own new keys');
483
Assert.areSame('z', receiver.a, '"a" should be overwritten');
484
Assert.areSame('foo', receiver.foo, '"foo" should be received');
486
Assert.areNotSame(receiver.obj, supplier.obj, 'objects should be merged, not overwritten');
487
Assert.areNotSame(receiver.obj.deep, supplier.obj.deep, 'deep objects should be merged, not overwritten');
488
Assert.areNotSame(receiver.obj.deep.deeper, supplier.obj.deep.deeper, 'deeper objects should be merged, not overwritten');
490
Assert.areSame('z', receiver.obj.a, 'objects should be merged');
491
Assert.areSame('b', receiver.obj.b, 'objects should be merged');
492
Assert.areSame('foo', receiver.obj.deep.foo, 'deep objects should be merged');
493
Assert.areSame('z', receiver.obj.deep.deeper.bar, 'deeper objects should be merged');
495
// Array merge (see http://yuilibrary.com/projects/yui3/ticket/2528405)
496
receiver = {a: [{x: 1}, {x: 2}]};
497
supplier = {a: [{y: 99}, {y: 98}]};
499
Y.mix(receiver, supplier, true, null, 0, true);
501
Assert.areSame(1, receiver.a[0].x, 'objects in arrays should be merged');
502
Assert.areSame(99, receiver.a[0].y, 'objects in arrays should be merged');
505
'test [mode 0]: overwrite, whitelist, merge': function () {
506
var receiver = {a: 'a', obj: {a: 'a', b: 'b', deep: {foo: 'foo', deeper: {bar: 'bar'}}}},
507
supplier = {a: 'z', foo: 'foo', bar: 'bar', obj: {a: 'z', deep: {deeper: {bar: 'z'}}}};
509
Y.mix(receiver, supplier, true, ['a', 'foo', 'deeper'], 0, true);
511
Assert.areSame(3, Y.Object.size(receiver), 'should own three keys');
512
ObjectAssert.ownsKeys(['a', 'foo', 'obj'], receiver, 'should own new keys');
513
Assert.areSame('z', receiver.a, '"a" should be overwritten');
514
Assert.areSame('foo', receiver.foo, '"foo" should be received');
516
Assert.areNotSame(receiver.obj, supplier.obj, 'objects should be merged, not overwritten');
517
Assert.areNotSame(receiver.obj.deep, supplier.obj.deep, 'deep objects should be merged, not overwritten');
518
Assert.areNotSame(receiver.obj.deep.deeper, supplier.obj.deep.deeper, 'deeper objects should be merged, not overwritten');
520
Assert.areSame('a', receiver.obj.a, 'non-whitelisted deep properties should not be overwritten');
521
Assert.areSame('b', receiver.obj.b, 'objects should be merged');
522
Assert.areSame('foo', receiver.obj.deep.foo, 'deep objects should be merged');
523
Assert.areSame('bar', receiver.obj.deep.deeper.bar, 'non-whitelisted deeper objects should be merged');
526
'test [mode 0]: overwrite, whitelist, toplevel merge': function() {
527
var receiver = {bar: true, foo:{a:1, b:2}},
528
supplier = {bar: false, foo:{c:3}};
530
Y.aggregate(receiver, supplier, true, ['foo']);
531
Y.mix(receiver, supplier, true, ['foo'], 0, true);
533
ObjectAssert.hasKeys(['a', 'b', 'c'], receiver.foo, "merge property with an object value from whitelist is missing properties");
534
ObjectAssert.areEqual({a:1, b:2, c:3}, receiver.foo, "merge property with an object value from whitelist doesn't have expected properties/values");
538
suite.add(new Y.Test.Case({
539
name: 'mix: mode 1 (prototype to prototype)',
542
this.supplier = function () {};
543
this.supplier.prototype = {a: 'z', foo: 'foo', bar: 'bar', obj: {a: 'z', deep: {deeper: {bar: 'z'}}}};
544
this.supplier.owned = "I'm an owned property!";
547
tearDown: function () {
548
delete this.supplier;
551
'test [mode 1]: no overwrite, no whitelist, no merge': function () {
552
var receiver = function () {};
555
Y.mix(receiver, this.supplier, false, null, 1);
557
Assert.areSame(1, Y.Object.size(receiver), 'should own one key');
558
Assert.areSame('a', receiver.a, '"a" should not be overwritten');
559
ObjectAssert.ownsKeys(['a', 'foo', 'bar', 'obj'], receiver.prototype, 'prototype should own new keys');
560
Assert.areSame('z', receiver.prototype.a, '"a" should exist on prototype');
563
'test [mode 1]: overwrite, no whitelist, no merge': function () {
564
var receiver = function () {};
567
receiver.prototype.a = 'a';
568
receiver.prototype.obj = {a: 'a', foo: 'foo'};
570
Y.mix(receiver, this.supplier, true, null, 1);
572
Assert.areSame(1, Y.Object.size(receiver), 'should own one key');
573
Assert.areSame('a', receiver.a, '"a" should not be overwritten on receiver');
574
Assert.areSame('z', receiver.prototype.a, '"a" should be overwritten on receiver\'s prototype');
575
Assert.areSame(this.supplier.prototype.obj, receiver.prototype.obj);
578
'test [mode 1]: overwrite, whitelist, no merge': function () {
579
var receiver = function () {};
581
receiver.prototype.a = 'a';
583
Y.mix(receiver, this.supplier, true, ['a', 'foo'], 1);
585
ObjectAssert.ownsNoKeys(receiver);
586
Assert.areSame(2, Y.Object.size(receiver.prototype));
587
Assert.areSame('z', receiver.prototype.a);
588
Assert.areSame('foo', receiver.prototype.foo);
591
'test [mode 1]: no overwrite, whitelist, no merge': function () {
592
var receiver = function () {};
594
receiver.prototype.a = 'a';
596
Y.mix(receiver, this.supplier, false, ['a', 'foo'], 1);
598
ObjectAssert.ownsNoKeys(receiver);
599
Assert.areSame(2, Y.Object.size(receiver.prototype));
600
Assert.areSame('a', receiver.prototype.a);
601
Assert.areSame('foo', receiver.prototype.foo);
604
'test [mode 1]: no overwrite, no whitelist, merge': function () {
605
var receiver = function () {};
607
receiver.prototype.obj = {a: 'a', foo: 'foo', deep: {deeper: {a: 'a'}}};
609
Y.mix(receiver, this.supplier, false, null, 1, true);
611
Assert.areNotSame(this.supplier.prototype.obj, receiver.prototype.obj);
612
Assert.areSame('a', receiver.prototype.obj.a);
613
Assert.areSame('foo', receiver.prototype.obj.foo);
614
Assert.areSame('a', receiver.prototype.obj.deep.deeper.a);
615
Assert.areSame('z', receiver.prototype.obj.deep.deeper.bar);
618
'test [mode 1]: overwrite, no whitelist, merge': function () {
619
var receiver = function () {};
621
receiver.prototype.obj = {a: 'a', foo: 'foo', deep: {deeper: {bar: 'a'}}};
623
Y.mix(receiver, this.supplier, true, null, 1, true);
625
Assert.areNotSame(this.supplier.prototype.obj, receiver.prototype.obj);
626
Assert.areSame('z', receiver.prototype.obj.a);
627
Assert.areSame('foo', receiver.prototype.obj.foo);
628
Assert.areSame('z', receiver.prototype.obj.deep.deeper.bar);
631
'test [mode 1]: overwrite, whitelist, merge': function () {
632
var receiver = function () {};
634
receiver.prototype.obj = {a: 'a', foo: 'foo', deep: {deeper: {bar: 'a'}}};
636
Y.mix(receiver, this.supplier, true, ['a', 'obj', 'deep'], 1, true);
638
Assert.isUndefined(receiver.prototype.bar);
639
Assert.areNotSame(this.supplier.prototype.obj, receiver.prototype.obj);
640
Assert.areSame('z', receiver.prototype.obj.a);
641
Assert.areSame('foo', receiver.prototype.obj.foo);
645
// The tests for other modes above cover the various mix options exhaustively.
646
// From here on, we're just doing sanity checks of the remaining modes.
648
suite.add(new Y.Test.Case({
649
name: 'mix: mode 2 (object to object and prototype to prototype)',
652
this.supplier = function () {};
653
this.supplier.prototype = {a: 'z', foo: 'foo', bar: 'bar', obj: {a: 'z', deep: {deeper: {bar: 'z'}}}};
654
this.supplier.owned = "I'm an owned property!";
657
tearDown: function () {
658
delete this.supplier;
661
'test [mode 2]: basic sanity check': function () {
662
var receiver = function () {};
664
Y.mix(receiver, this.supplier, false, null, 2);
666
ObjectAssert.ownsKeys(['a', 'foo', 'bar', 'obj'], receiver.prototype);
667
ObjectAssert.ownsKey('owned', receiver);
671
suite.add(new Y.Test.Case({
672
name: 'mix: mode 3 (prototype to object)',
675
this.supplier = function () {};
676
this.supplier.prototype = {a: 'z', foo: 'foo', bar: 'bar', obj: {a: 'z', deep: {deeper: {bar: 'z'}}}};
677
this.supplier.owned = "I'm an owned property!";
680
tearDown: function () {
681
delete this.supplier;
684
'test [mode 3]: basic sanity check': function () {
685
var receiver = function () {};
687
Y.mix(receiver, this.supplier, false, null, 3);
689
ObjectAssert.ownsKeys(['a', 'foo', 'bar', 'obj'], receiver);
690
ObjectAssert.ownsNoKeys(receiver.prototype);
691
Assert.isUndefined(receiver.owned);
695
suite.add(new Y.Test.Case({
696
name: 'mix: mode 4 (object to prototype)',
699
this.supplier = function () {};
700
this.supplier.prototype = {a: 'z', foo: 'foo', bar: 'bar', obj: {a: 'z', deep: {deeper: {bar: 'z'}}}};
701
this.supplier.owned = "I'm an owned property!";
704
tearDown: function () {
705
delete this.supplier;
708
'test [mode 4]: basic sanity check': function () {
709
var receiver = function () {};
711
Y.mix(receiver, this.supplier, false, null, 4);
713
ObjectAssert.ownsKey('owned', receiver.prototype);
714
ObjectAssert.ownsNoKeys(receiver);
718
Y.Test.Runner.add(suite);
720
}, '@VERSION@', {requires: ['attribute', 'test']});