1
1
/**
2
2
* @licence GNU GPL v2+
3
3
* @author H. Snater < mediawiki@snater.com >
4
+ * @author Thiemo Mättig
4
5
*/
5
6
define ( [
6
7
'globeCoordinate/globeCoordinate' ,
@@ -92,7 +93,7 @@ define( [
92
93
93
94
} ) ;
94
95
95
- QUnit . test ( 'equals() ' , function ( assert ) {
96
+ QUnit . test ( 'Strict (in)equality ' , function ( assert ) {
96
97
var gcDefs = [
97
98
{ latitude : 0 , longitude : 0 , precision : 1 } ,
98
99
{ latitude : - 3 , longitude : 2 , precision : 1 } ,
@@ -114,28 +115,64 @@ define( [
114
115
$ . each ( gcDefs , function ( i2 , gcDef2 ) {
115
116
c2 = new globeCoordinate . GlobeCoordinate ( gcDef2 ) ;
116
117
117
- if (
118
- gcDef1 . latitude === gcDef2 . latitude
118
+ if ( gcDef1 . latitude === gcDef2 . latitude
119
119
&& gcDef1 . longitude === gcDef2 . longitude
120
120
&& gcDef1 . precision === gcDef2 . precision
121
121
) {
122
-
123
122
assert . ok (
124
123
c1 . equals ( c2 ) ,
125
124
'Validated equality for data set #' + i1 + '.'
126
125
) ;
127
-
128
126
} else {
129
-
130
127
assert . ok (
131
128
! c1 . equals ( c2 ) ,
132
129
'Validated inequality of data set #' + i1 + ' to #' + i2 + '.'
133
130
) ;
134
-
135
131
}
136
-
137
132
} ) ;
133
+ } ) ;
134
+
135
+ } ) ;
136
+
137
+ QUnit . test ( 'Loose equality' , function ( assert ) {
138
+ var gcDefs = [
139
+ { latitude : 0 , longitude : 0 , precision : 1 } ,
140
+ { latitude : 0.01 , longitude : 0 , precision : 1 } ,
141
+ { latitude : 0.1 , longitude : 0 , precision : 1 } ,
142
+ { latitude : 0 , longitude : 0.01 , precision : 1 } ,
143
+ { latitude : 0 , longitude : 0.1 , precision : 1 } ,
144
+ { latitude : 0 , longitude : 0 , precision : 1.000000001 } ,
145
+ { latitude : 0 , longitude : 0 , precision : 1.00000001 }
146
+ ] ,
147
+ c1 = new globeCoordinate . GlobeCoordinate ( gcDefs [ 0 ] ) ;
148
+
149
+ $ . each ( gcDefs , function ( i2 , gcDef2 ) {
150
+ var c2 = new globeCoordinate . GlobeCoordinate ( gcDef2 ) ;
151
+ assert . ok (
152
+ c1 . equals ( c2 ) ,
153
+ 'Validated equality of data set #0 to #' + i2 + '.'
154
+ ) ;
155
+ } ) ;
156
+
157
+ } ) ;
138
158
159
+ QUnit . test ( 'Loose inequality' , function ( assert ) {
160
+ var c1 = new globeCoordinate . GlobeCoordinate (
161
+ { latitude : 0 , longitude : 0 , precision : 1 / 3600 }
162
+ ) ,
163
+ gcDefs = [
164
+ { latitude : 0.0002 , longitude : 0 , precision : 1 / 3600 } ,
165
+ { latitude : 0 , longitude : 0.0002 , precision : 1 / 3600 } ,
166
+ { latitude : 0 , longitude : 0 , precision : 1 / 3600 + 0.0000001 } ,
167
+ { latitude : 0 , longitude : 0 , precision : 1 / 3600 - 0.0000001 }
168
+ ] ;
169
+
170
+ $ . each ( gcDefs , function ( i2 , gcDef2 ) {
171
+ var c2 = new globeCoordinate . GlobeCoordinate ( gcDef2 ) ;
172
+ assert . ok (
173
+ ! c1 . equals ( c2 ) ,
174
+ 'Validated inequality to data set #' + i2 + '.'
175
+ ) ;
139
176
} ) ;
140
177
141
178
} ) ;
0 commit comments