Ejemplo n.º 1
0
	it("last", function() {
		assert.equal(util.last([1, 2, 3]), 3);
		assert.deepEqual(util.last([1, 2, 3], 0), []);
		assert.deepEqual(util.last([1, 2, 3], 2), [2, 3]);
		assert.deepEqual(util.last([1, 2, 3], 5), [1, 2, 3]);

		assert.equal(util.last(null), undefined);
		assert.strictEqual(util.last([1, 2, 3], -1).length, 0);
	});
Ejemplo n.º 2
0
    it('clone', () => {
        assert.equal(util.clone(100), 100);

        var a = [100, 200];
        var a1 = util.clone(a);
        assert.notEqual(a, a1);
        assert.deepEqual(a, a1);
        a[0] = 150;
        assert.notDeepEqual(a, a1);

        var o = {
            a: 100,
            b: 200
        };
        var o1 = util.clone(o);
        assert.notEqual(o, o1);
        assert.deepEqual(o, o1);
        o["a"] = 150;
        assert.notDeepEqual(o, o1);

        var moe = {
            name: 'moe',
            lucky: [13, 27, 34]
        };
        var clone = util.clone(moe);
        assert.strictEqual(clone.name, 'moe', 'the clone as the attributes of the original');

        clone.name = 'curly';
        assert.ok(clone.name === 'curly' && moe.name === 'moe', 'clones can change shallow attributes without affecting the original');

        clone.lucky.push(101);
        assert.strictEqual(util.last(moe.lucky), 101, 'changes to deep attributes are shared with the original');

        assert.strictEqual(util.clone(void 0), void 0, 'non objects should not be changed by clone');
        assert.strictEqual(util.clone(1), 1, 'non objects should not be changed by clone');
        assert.strictEqual(util.clone(null), null, 'non objects should not be changed by clone');
    });
Ejemplo n.º 3
0
Viewport.prototype.zoomOut = function() {
  this.zoom = util.last(zooms, It['<'](this.zoom), this.zoom)
}