Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/ext/test/unit/Array.js @ 81

Revision 76, 2.7 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/*!
2 * Ext JS Library 3.4.0
3 * Copyright(c) 2006-2011 Sencha Inc.
4 * licensing@sencha.com
5 * http://www.sencha.com/license
6 */
7Ext.test.session.addTest('Array', {
8
9    name: 'Global Array Decorators',
10   
11    planned: 17,
12   
13    setUp: function(){
14        this.Cls = Ext.extend(Object, {});
15    },
16   
17    // 12
18    test_indexOf: function(){
19        Y.Assert.areEqual(-1, [].indexOf(1), 'Test with an empty array');
20        Y.Assert.areEqual(-1, [0, 1, 2].indexOf(3), 'Test with numbers where the item should not exist');
21        Y.Assert.areEqual(1, [0, 1, 2].indexOf(1), 'Test with numbers where the item should exist');
22        Y.Assert.areEqual(3, [0, 3, 2, 1, 4, 5, 6, 7, 1, 2].indexOf(1), 'Test with numbers where the item exists a number of times');
23        Y.Assert.areEqual(-1, ['x', 'y', 'z'].indexOf('X'), 'Test with strings where the item should not exist');
24        Y.Assert.areEqual(0, ['a', 'x', 'y', 'z'].indexOf('a'), 'Test with strings where the item should exist');
25        Y.Assert.areEqual(-1, [0, 1, 2].indexOf('1'), 'Test to ensure type coercion doesn\'t occur');
26       
27        var c1 = new this.Cls(), 
28            c2 = new this.Cls(), 
29            c3 = new this.Cls(), 
30            c4 = new this.Cls();
31       
32        Y.Assert.areEqual(-1, [c1, c2, c3, c4].indexOf(new this.Cls()), 'Test with object instances, item should not exist');
33        Y.Assert.areEqual(2, [c1, c2, c3, c4].indexOf(c3), 'Test with object instances, item should exist');
34       
35        //test the from parameter
36        Y.Assert.areEqual(-1, [1, 2, 3, 4, 5].indexOf(1, 3), 'Test where the item exists past the from parameter');
37        Y.Assert.areEqual(-1, [1, 2, 3, 4, 5].indexOf(1, 50), 'Test where the item exists, but the index is greater than the array');
38        Y.Assert.areEqual(7, [1, 2, 3, 4, 5, 6, 7, 3].indexOf(3, 4), 'Test where the item more than once, the from should refer to the second item');
39    },
40   
41    // 5
42    test_remove: function(){
43        var arr = [];
44       
45        arr.remove(1);
46        Y.ArrayAssert.isEmpty(arr, 'Test with an empty array');
47       
48        arr = [1, 2, 3];
49        arr.remove(1);
50        Y.ArrayAssert.itemsAreEqual([2, 3], arr, 'Test with a simple removal');
51       
52        arr = [1, 2, 3, 1];
53        arr.remove(1);
54        Y.ArrayAssert.itemsAreEqual([2, 3, 1], arr, 'Test where the item exists more than once');
55       
56        arr = [1, 2, 3, 4];
57        arr.remove(100);
58        Y.ArrayAssert.itemsAreEqual([1, 2, 3, 4], arr, 'Test where the item doesn\'t exist');
59       
60        var c1 = new this.Cls(), 
61            c2 = new this.Cls(), 
62            c3 = new this.Cls();
63       
64        arr = [c1, c2, c3];
65        arr.remove(c2);
66        Y.ArrayAssert.itemsAreEqual([c1, c3], arr, 'Test with object instances');
67    }
68   
69});
Note: See TracBrowser for help on using the repository browser.